您的位置:首页 > 其它

【数论】HDU 4952 Number Transformation

2014-08-14 21:57 288 查看
x2*(i+1)>=x1*i;

->x2=x1*i/(i+1);

不断求直到x2<i为止

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#define IN freopen ("in.txt" , "r" , stdin);
#define OUT freopen ("out.txt" , "w" , stdout);
typedef __int64 LL;
const int MAXN = 2222;//点数的最大值
const int MAXM = 111111;//边数的最大值
const LL INF = 1152921504;
const int mod=1000000007;
int main()
{
LL n,k,cas=1;
while(scanf("%I64d%I64d",&n,&k),n+k)
{
LL i;
for(i=1;i<k;i++)
{
n=n-n/(i+1);
if(n<i+1)
break;
}
printf("Case #%I64d: %I64d\n",cas++,n*k);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: