数论
求i倍数的倍数k*i,转化为求k
题解:(这里的x*i才相当于题目中x)
题目:
Number Transformation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 84 Accepted Submission(s): 30
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
Source
Accepted
62MS | 376K |
/*
* Author: NICK WONG
* Created Time: 8/14/2014 15:59:05
* File Name: 1008.cpp
*/
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
#define out(x) cout<<#x<<": "<<x<<endl
const double eps(1e-8);
const int maxn=10100;
const long long maxint=-1u>>1;
const long long maxlong=maxint*maxint;
typedef long long lint;
lint x,s,st,tmp,en;
int turn;
void init()
{
}
void work()
{
for (lint i=1; i<s; i++)
{
if (x<i+1) break; else x=x-x/(i+1);
}
cout<<"Case #"<<++turn<<": "<<x*s<<endl;
}
int main()
{
while(cin>>x>>s)
{
if (x+s==0) break;
init();
work();
}
return 0;
}