ACM 数论 hdu4952

数论 

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

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
 


Accepted 

62MS376K

/*
 * 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;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值