数论 Number Transformation HDU4952

已知n,k,操作k次,每次操作求大于n且能被次数i整除的最小的数

已知x*i,所以(i+1)*y>=x*i,y>=x-[x/(i+1)],当x<i+1时,y的值不再改变,直接break,输出y*k即可(x,y都是倍数)

#include <stdio.h>
int main()
{
    long long n,k;
    long long i;
    int time=0;
    while(scanf("%I64d%I64d",&n,&k)!=-1)
    {
        if(n==0&&k==0)
            break;
        time++;
        for(i=2;i<=k;i++)             //从2开始,应为n就是i=1时的倍数
        {
            n=n-n/i;
            if(n<i)                   //n<i+1
                break;
        }
        printf("Case #%d: %I64d\n",time,n*k);
    }
    return 0;
}

数论 Number Transformation HDU4952

时间: 2024-08-04 04:42:51

数论 Number Transformation HDU4952的相关文章

HDU-4952 Number Transformation

http://acm.hdu.edu.cn/showproblem.php?pid=4952 Number Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 171    Accepted Submission(s): 69 Problem Description Teacher Mai has an inte

hdu4952 Number Transformation(数学题 | 找规律)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4952 Number Transformation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 261    Accepted Submission(s): 117 Problem Description Teacher Mai has

HDU4952:Number Transformation

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 mult

HDU 4952 Number Transformation 多校8 机智数学

哎.这个题想了好久,状态不对啊...一个大家都出的题..当时想到肯定是可以有什么规律来暴力,不用算到10的10次方 对于某个k,x.从1到k循环,每次求一个新的x,这个x要大于等于原x,并且要是i的倍数... 一直觉得有规律可循,后来知道就是倍数,我们设倍数为 b, 则b2*(i+1)>=b1*(i);可以知道b2>=b1-b1/(i+1),则,b2在b1小于等于i+1的时候便不会再变换,题目最大的倍数为10的10次方,根据第一个式子,最多经过10的五次方,倍数就会缩为10的五次方,此时i也&

hdu 4952 Number Transformation (找规律)

题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值,求出这个固定的值和K相乘就可以了, 为什么会趋于固定的值呢,因为最后虽然i在不断增长,但是x也是在增长的,每次的倍数会回退一个发现 有余数,然后再加上一个,所以趋于稳定. 官方题解: 1 #include <iostream> 2 #include <cstdio> 3 #includ

bzoj 3858: Number Transformation

3858: Number Transformation Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 82  Solved: 41[Submit][Status] 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 th

Codeforces 346C Number Transformation II 构造

题目链接:点击打开链接 = = 990+ms卡过 #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> #include<vector> #include<set> using namespace std; #define N 100010 #define L(x) (x<<1) #define R(x) (x<<

HDU 4952 Number Transformation(公式)

HDU Number Transformation 题目链接 题意:按题目中要求求出最后的n 思路:推公式(i+1)x′>=ix,得到x′>=1+floor(xi+1),这样一来就可以递推x,那么注意题目中k很大,但是实际上如果i到一定数值之后,x就不会在增长了,这时候就可以break了 代码: #include <cstdio> #include <cstring> typedef long long ll; ll n, k; int main() { int cas

HDU 4952 Number Transformation 规律题

打表可以知道到后面增量都一样了,, 推论就是  i 和 i+1 互质 #include <cstdio> #include <algorithm> #include <cstring> #include <iostream> using namespace std; typedef long long ll; const ll mx = 120000; int main() { int cas = 0; ll x, k, y, dis, i; while (