【数论】HDU 4952 Number Transformation

来源:互联网 发布:淘宝如何出售虚拟物品 编辑:程序博客网 时间:2024/06/05 15:02

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


0 0
原创粉丝点击