# 第3、6点会WA的，把double的精度整大一点

#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
double p,q;
scanf("%lf%lf",&p,&q);
p*=0.01;q*=0.01;
p+=0.0000000001;q-=0.0000000001;
for (register double i=1;;i+=1)
if(floor(q*i)-floor(p*i)) {printf("%d",(int)i); return 0;}
return 0;
}

# 1 条评论

• @ 2018-07-01 13:01:46
``````#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i=1;i<=n;i++)
#define REP(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define pos(x,y) (x+(y)*n)
const int N=100000+10;
const int inf=0x3f3f3f3f;
const ll mod=1000000007;
const double eps=1e-8;

double p,q;
int main() {
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>p>>q;
p*=0.01,q*=0.01;
p+=0.0000000001;q-=0.0000000001;
int l=1,r=1000000;
int mid=0;
int ans=0;
while (l<=r) {
mid=(l+r)>>1;
if (int(mid*p)<=int(mid*q)-1) {
ans=mid;
r=mid-1;
} else {
l=mid+1;
}
}
cout<<ans<<endl;
return 0;
}
``````

为什么这样不行？会WA

• 1

ID
1041

6

(无)

8076

2265

28%