HDU 4952 Number Transformation

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 612 Accepted Submission(s): 310

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.



 

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).


 

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


 

Source


 

Recommend

hujie | We have carefully selected several similar problems for you: 4955 4954 4953 4951 4950



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cassert>
#include<utility>
#include<numeric>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define pr pair
#define PR pair<int,int>
#define MP make_pair
#define SI(x) set<x>::iterator
#define VI(x) vector<x>::iterator
#define MI(x,y) map<x,y>::iterator
#define SRI(x) set<x>::reverse_iterator
#define VRI(x) vector<x>::reverse_iterator
#define MRI(x,y) map<x,y>::reverse_iterator
#define F first
#define S second
#define Sz(x) (int)x.size()
#define clrQ(x) while(!x.empty)x.pop();
#define clr(x,y) memset(x,y,sizeof(x));
#if defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__)
#define LL __int64
#define LLS "%" "I" "6" "4" "d"
#define LLU "%" "I" "6" "4" "u"
#define LL_MAX _I64_MAX
#else
#define LL long long
#define LLS "%" "l" "l" "d"
#define LLU "%" "l" "l" "u"
#define LL_MAX _I64_MAX
#endif
const int inf = ~0u >> 1;
const LL lnf = ~0ull >> 1;
/*start*/
int __;
#define type LL
inline type getint() {
    type ret=0;bool ok=0;
    for(;;) {
        int c=getchar();
        if(c>='0'&&c<='9')ret=(ret<<3)+ret+ret+c-'0',ok=1;
        else if(ok)return ret;
    }
}
#undef type
int main(int argc, char **argv) {
    LL x, k;
    while (1) {
        x=getint();
        k=getint();
        if (x == 0 && k == 0) break;
        for(int i=1;i<k;i++){
            if(x<i+1)break;
            x-=x/(i+1);
        }
        printf("Case #%d: "LLS"\n",++__,x*k);
    }
}