WA了好多次,后來發現是忽略了一種情況。注意是開區間,因此(7.7,8)這樣的情況是不允許的,對于(a,b),b不能為整數。
以下是我的代碼:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
/*
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
//*/
int ans;
double P,Q;
cin>>P>>Q;
for(ans=1; ;ans++)
{
int a=(int)(100*P*ans),
b=(int)(100*Q*ans);
if(b/10000-a/10000>=1 && b%10000!=0)
break;
}
cout<<ans<<endl;
return 0;
}
posted on 2011-02-21 21:46
lee1r 閱讀(272)
評論(0) 編輯 收藏 引用 所屬分類:
題目分類:數學/數論