点击打开链接题目链接
Number Transformation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 308 Accepted Submission(s): 139
Problem Description
Teacher Mai has an integer x.
He does the following operations k times. In the i-th operation, x becomes the least integer no less than x, which is the multiple of i.
He wants to know what is the number x now.
He does the following operations k times. In the i-th operation, x becomes the least integer no less than x, which is the multiple of i.
He wants to know what is the number x now.
Input
There are multiple test cases, terminated by a line "0 0".
For each test case, the only one line contains two integers x,k(1<=x<=10^10, 1<=k<=10^10).
For each test case, the only one line contains two integers x,k(1<=x<=10^10, 1<=k<=10^10).
Output
For each test case, output one line "Case #k: x", where k is the case number counting from 1.
Sample Input
2520 10 2520 20 0 0
Sample Output
Case #1: 2520 Case #2: 2600
#include<stdio.h>
#include<string.h>
#include<math.h>
__int64 x;
__int64 k;
__int64 y;
int main()
{
int cas=0;
while(scanf("%I64d %I64d",&x,&k)!=EOF&&(x||k))
{
__int64 i,sum;
for(i=1;i<k;i++)
{
y=x-(x/(i+1));
if(x==y)
{
break;
}
x=y;
}
sum=x*k;
printf("Case #%d: %I64d\n",++cas,sum);
}
return 0;
}