• 多校7 1005 The shortest problem


    The shortest problem

    Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 2301    Accepted Submission(s): 607


    Problem Description
    In this problem, we should solve an interesting game. At first, we have an integer n, then we begin to make some funny change. We sum up every digit of the n, then insert it to the tail of the number n, then let the new number be the interesting number n. repeat it for t times. When n=123 and t=3 then we can get 123->1236->123612->12361215.
     
    Input
    Multiple input.
    We have two integer n (0<=n<=104 ) , t(0<=t<=105) in each row.
    When n==-1 and t==-1 mean the end of input.
     
    Output
    For each input , if the final number are divisible by 11, output “Yes”, else output ”No”. without quote.
     
    Sample Input
    35 2 35 1 -1 -1
     
    Sample Output
    Case #1: Yes Case #2: No
     1 #include <stdio.h>
     2 
     3 int ss(int x)
     4 {
     5     int i,j,su=0;
     6     while(x)
     7     {
     8         su=su+x%10;
     9         x=x/10;
    10     }
    11     return su;
    12 }
    13 
    14 int sss(int x)
    15 {
    16     int cnt=0;
    17     while(x)
    18     {
    19         cnt++;
    20         x=x/10;
    21     }
    22     return cnt;
    23 }
    24 
    25 int dd(int x,int y)
    26 {
    27     int i;
    28     for(i=1;i<=y;i++)
    29         x=x*10;
    30     return x;
    31 }
    32 
    33 int main()
    34 {
    35     int n,t,s,mo;
    36     int i,j,k,ca=0;
    37     while(scanf("%d %d",&n,&t)!=EOF)
    38     {
    39         if(n==-1 && t==-1)
    40             break;
    41         s=ss(n),mo=n%11;
    42         //printf("$%d %d
    ",mo,s);
    43         for(i=1;i<=t;i++)
    44         {
    45             mo=(dd(mo,sss(s))+s)%11;
    46             s=s+ss(s);
    47             //printf("$%d %d
    ",mo,s);
    48         }
    49         printf("Case #%d: ",++ca);
    50         if(mo==0)
    51             printf("Yes
    ");
    52         else
    53             printf("No
    ");
    54     }
    55 }
    View Code
  • 相关阅读:
    在Linux下安装和使用MySQL
    vc动态装载动态库
    stl学习(转帖2)
    makefile
    详细的MySQL C API
    Excel INTO SQLSERVER
    Outlook2010中预览Word,Excel附件问题
    11gRAC ASM管理的数据文件丢失恢复
    ASM上控制文件损坏时的恢复
    使用NET USER增加一个超级管理 & 激活Windows 7 administrator
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771390.html
Copyright © 2020-2023  润新知