hdu4952Number Transformation (找规律)

Number Transformation

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 76 Accepted Submission(s): 28

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

#include<stdio.h>
int main()
{
    __int64 x,k,i,j,t=0;
    while(scanf("%I64d%I64d",&x,&k)>0&&(x||k))
    {
        i=2;
        while(i<=k)
        {
            if(x%i!=0)
            {
                j=x/i+1; if(j<=i){x=j*k;break;}
                x=i*j;
            }
            else
            {
                j=x/i; if(j<=i){x=j*k;break;}
            }
            i++;
        }
        printf("Case #%I64d: %I64d\n",++t,x);
    }
}

hdu4952Number Transformation (找规律)

时间: 2024-10-23 03:22:10

hdu4952Number Transformation (找规律)的相关文章

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

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

HDU ACM 1041Computer Transformation(大数模拟+找规律)

分析:大数模拟和找规律. #include<iostream> using namespace std; char f[1001][501]; /* 从下面的步骤中可以看出,下一步的后半部分是前一步的整个串,所以对于后半部分有f[n]=f[n-1]: 从前半部分和整体可以看出,另一部分有f[n]=f[n-1]-1(奇数步),f[n]=f[n-1]+1(偶数步). step0:1 f[0]=0 step1:01 f[1]=0 step2:10 01 f[2]=1 =2*f[1]+1 step3:

HDU 1041 Computer Transformation(找规律加大数乘)

主要还是找规律,然后大数相乘 #include<stdio.h> #include<string.h> #include<math.h> #include<time.h> #include<map> #include<iostream> #include<ctype.h> #include<string> #include<algorithm> #include<stdlib.h> #i

The Cow Lineup_找规律

Description Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled with a number in the range 1...K (1 <= K <=10,000) identifying her breed. For example, a line of 14 cows might have these breeds: 1 5 3 2 5 1 3 4 4

UVA - 1646 - Edge Case(找规律)

题意:n(3 <= n <= 10000)个结点组成一个圈,求匹配(即没有公共点的边集)的个数. 找规律为斐波那契的性质,因为数太大所以用的java大数. import java.math.BigInteger; import java.util.Scanner; public class Main{ public static int MAXN = 10000 + 10; public static BigInteger []c = new BigInteger[MAXN]; public

【55测试】【字符串】【栈】【找规律】

集训第二天,额,考崩了. 第一题 hao 大意:(这个名字就不要在意了,其实是祖玛游戏) 模拟祖玛游戏的模式,给一个'A'~'Z'的字符串,然后有t个插入操作为 “ 添加后的在原字符串的位置 x  插入元素 c ”,字符串中有超过或等于 3 个相同的字符,则被消除,输出每次操作后剩余的字符串,如果为空,则输出“-”. 样例: ACCBA                     输出:  ABCCBA 5   AABCCBA 1 B AABBCCBA 0 A - 2 B A 4 C 0 A 解:

2016(胡赛复现)_大数找规律

Time Limit: 5 Sec  Memory Limit: 128 MB Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m;  2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000

HDU 5703 Desert 水题 找规律

已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这题输出二进制数就行了......那就更简单了,直接输出1,然后后面跟n-1个0就行了╮(╯_╰)╭ 下面AC代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>