• hdu 4952


    Number Transformation

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 418    Accepted Submission(s): 201

    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
     
    Recommend
    hujie
     
     
    必须强调,不会的题一定不要偷懒,打表!!!!!!!!!!!!!!
     
     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdlib>
     4 #include<cstdio>
     5 #include<algorithm>
     6 #include<cmath>
     7 #include<queue>
     8 #include<map>
     9 
    10 #define N 1505
    11 #define M 15
    12 #define mod 1000000007
    13 #define mod2 100000000
    14 #define ll long long
    15 #define maxi(a,b) (a)>(b)? (a) : (b)
    16 #define mini(a,b) (a)<(b)? (a) : (b)
    17 
    18 using namespace std;
    19 
    20 ll x,k,i,tmp;
    21 int cnt;
    22 /*
    23 void ini()
    24 {
    25     int i,k,j;
    26     for(i=1;i<=15;i++){
    27         for(k=1;k<=15;k++){
    28             int x=i;
    29             for(j=1;j<=k;j++){
    30                 while(x%j!=0){
    31                     x++;
    32                 }
    33             }
    34             printf(" i=%d k=%d x=%d
    ",i,k,x);
    35         }
    36     }
    37 }*/
    38 
    39 int main()
    40 {
    41     //ini();
    42     //freopen("data.in","r",stdin);
    43     //scanf("%d",&T);
    44     //for(int cnt=1;cnt<=T;cnt++)
    45     //while(T--)
    46     cnt=1;
    47     while(scanf("%I64d%I64d",&x,&k)!=EOF)
    48     {
    49         if(x==0 && k==0) break;
    50         printf("Case #%d: ",cnt);cnt++;
    51         tmp=-1;
    52         for(i=1;i<=k;i++){
    53             if(x%i!=0){
    54                 x=(x/i+1)*i;
    55                 
    56             }
    57             if(x%i==0 && (x/i)==i-1){
    58                     //printf(" i=%I64d i-1=%I64d x=%I64d
    ",i,x/(i),x);
    59                     tmp=x/i;
    60                     break;
    61                 }
    62         }
    63         if(tmp==-1){
    64             printf("%I64d
    ",x);
    65         }
    66         else printf("%I64d
    ",tmp*(k-i)+x);
    67     }
    68 
    69 
    70 
    71     return 0;
    72 }
  • 相关阅读:
    [Angular 2] Refactoring mutations to enforce immutable data in Angular 2
    人物-释-鸠摩罗什:鸠摩罗什
    汉语-词语:说法
    汉语-词语:做法
    汉语-词语:办法
    汉语-词语:想法
    汉语-词语:看法
    汉语-词语:观念
    汉语-词语:逻辑
    汉语-词语:实质
  • 原文地址:https://www.cnblogs.com/njczy2010/p/3913541.html
Copyright © 2020-2023  润新知