【数论】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;
}
->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;
}
相关文章推荐
- hdu 4952 Number Transformation(数论)
- 【数论】HDU 4952 Number Transformation
- hdu 4952 Number Transformation 多校八 数论
- HDU 4952 Number Transformation 数论
- HDU 1163(即周赛F题)数论数根
- hdu 5428 The Factor(数论)
- hdu - 6096 Counting Divisors (数论计算约数的个数+思路)
- hdu 5391 (数论)
- ACM 数论 HDU 3037 Saving Beans (Lucas定理,大数取魔)
- HDU 4861 Couple doubi (数论)
- HDU 5974 A Simple Math Problem (数论+解方程组)
- HDU 2040 亲和数 -数论
- 【数论-莫比乌斯】hdu 6053 TrickGCD
- hdu 5239 Doom(线段树+数论)
- hdu 2685(数论相关定理+欧几里德定理+快速取模)
- hdu 4335多校4数论
- Squarefree number HDU - 3826(数论)
- 【数论】hdu 6069 Counting Divisors
- HDU 4952 Number Transformation
- hdu 4335 What is N? 数论