您的位置:首页 > 其它

hdu4803

2015-11-14 20:40 537 查看
#include <cstdio>
#include <cmath>
#define eps 1e-5
using namespace std;

double x,y;
int ans,n;

int main()
{
while (scanf("%lf%lf",&x,&y)!=EOF)
{
ans=(int)(x-1);
y-=x-1+eps;
if (y<0)
{
printf("-1\n");
continue;
}
for (int i=1; i<=x; i++)
{
n=(int)(i*y/x);
ans+=n;
y-=n*x/i;
if (y<1) break;
}
printf("%d\n",ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: