心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
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 阅读(255) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:数学/数论

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理