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
[ 2014 Multi-University Training Contest 8 ](http://acm.hdu.edu.cn/search.php?field=problem&key=2014%20Multi-University%20Training%20Contest%208&source=1&searchmode=source)
Recommend
hujie | We have carefully selected several similar problems for you: [4955](http://acm.hdu.edu.cn/showproblem.php?pid=4955) [4954](http://acm.hdu.edu.cn/showproblem.php?pid=4954) [4953](http://acm.hdu.edu.cn/showproblem.php?pid=4953) [4951](http://acm.hdu.edu.cn/showproblem.php?pid=4951) [4950](http://acm.hdu.edu.cn/showproblem.php?pid=4950)
#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);
}
}