【数论】HDU 4952 Number Transformation

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;
}


posted @ 2014-08-14 21:57  kewowlo  阅读(118)  评论(0)    收藏  举报