in
1
100 25 6
out
No
以下两个代码提交后都是AC的。
这个代码输出 Yes:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int T;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while(T--)
{
ll h,x,y;
cin >> h >> x >> y;
if(y>=h)
cout << "Yes\n";
else if(x>=h)
cout << "No\n";
else if(y==0)
cout << "No\n";
else if(x==0)
cout << "Yes\n";
else
{
ll times=h/x+1;
h=(h%x ? h%x : x);
cout << (times*y>=h ? "Yes\n" : "No\n");
}
}
return 0;
}
这个代码输出 No:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int T;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while(T--)
{
ll h,x,y;
cin >> h >> x >> y;
if(y>=h)
cout << "Yes\n";
else if(x>=h)
cout << "No\n";
else if(y==0)
cout << "No\n";
else if(x==0)
cout << "Yes\n";
else
{
ll times=h/x+(h%x ? 0 : -1)+1;
h=(h%x ? h%x : x);
cout << (times*y>=h ? "Yes\n" : "No\n");
}
}
return 0;
}
有好多题解用的都是上面那种写法。