题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373

一开始想到用整除11的性质去做,即奇位数的和和偶位数的和的差为11的倍数,但估不准数据范围没敢去做,

尝试去敲大数,HFZ想出了一个比较巧的方法,模拟计算的过程,用变量去存sum,sum = sum + 各位数字之和,

如果更新后的num是11的倍数,num就可以归0了,极大简化了过程,Int范围内就可以做。代码如下:

 #include<stdio.h>

 int get_sum(int x){
     ;
     while(x){
         sum += x%;
         x /= ;
     }
     return sum;
 }

 int get_lgt(int x){
     ;
     while(x >= base){
         ;
     }
     return base;
 }

 int main(){
     int num;
     int n;
     int sum;
     int lgt;
     ;
     while(scanf("%d %d",&num,&n)){
          && n == -)
             break;
         if(n){
             sum = ;
             sum = sum+get_sum(num);
             num %= ;
             lgt = get_lgt(sum);
             num = num*lgt+sum;
         }
         ; i < n; ++i){
             //sum一直存sum,num一直存目前的数
             sum = sum+get_sum(sum);
             num %= ;
             lgt = get_lgt(sum);
             num = num*lgt+sum;
         }
         printf("Case #%d: ",++T);

         ))
             puts("Yes");
         else
             puts("No");
     }
 }

hdoj 5373 The shortest problem的更多相关文章

  1. 同余模定理 HDOJ 5373 The shortest problem

    题目传送门 /* 题意:题目讲的很清楚:When n=123 and t=3 then we can get 123->1236->123612->12361215.要求t次操作后, ...

  2. hdu 5373 The shortest problem(杭电多校赛第七场)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 The shortest problem Time Limit: 3000/1500 MS (J ...

  3. 2015 Multi-University Training Contest 7 hdu 5373 The shortest problem

    The shortest problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  4. HDU 5373 The shortest problem (数学)

    题意:给定两个数的n和m,有一种操作,把 n 的各位数字加起来放到 n后面形成一个新数n,问重复 m 次所得的数能否整除 11. 析:这个题首先要知道一个规律奇数位的和减去偶数位的和能被11整除的数字 ...

  5. HDU-5373 The shortest problem

    The shortest problem http://acm.hdu.edu.cn/showproblem.php?pid=5373 Time Limit: 3000/1500 MS (Java/O ...

  6. The shortest problem

    The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...

  7. Manacher HDOJ 5371 Hotaru's problem

    题目传送门 /* 题意:求形如(2 3 4) (4 3 2) (2 3 4)的最长长度,即两个重叠一半的回文串 Manacher:比赛看到这题还以为套个模板就行了,因为BC上有道类似的题,自己又学过M ...

  8. The shortest problem(hdu,多校

    The shortest problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  9. HDU 5373(2015多校7)-The shortest problem(模拟%11)

    题目地址:pid=5373">HDU 5373 题意:给你一个数n和操作次数t,每次操作将n的各位数之和求出来放在n的末尾形成新的n,问t次操作后得到的n能否够被11整除. 思路:就是 ...

随机推荐

  1. 4.0之后的hibernate获取sessionFactory

    static{ Configuration config=new Configuration().configure(); ServiceRegistry resgistry = new Servic ...

  2. BZOJ 2151 种树

    贪心+priority_queue. #include<iostream> #include<cstdio> #include<cstring> #include& ...

  3. Java笔记之String

    1. String s="a",t="b"; t.concat(s); 之后,t仍然是"b",而不是"ba",要使t是& ...

  4. maven整合s2sh截图

  5. Python argparse

    http://songpengfei.iteye.com/blog/1440158 https://docs.python.org/2/library/argparse.html http://sta ...

  6. 【原创】牛顿法和拟牛顿法 -- BFGS, L-BFGS, OWL-QN

    数据.特征和数值优化算法是机器学习的核心,而牛顿法及其改良(拟牛顿法)是机器最常用的一类数字优化算法,今天就从牛顿法开始,介绍几个拟牛顿法算法.本博文只介绍算法的思想,具体的数学推导过程不做介绍. 1 ...

  7. hadoop——配置eclipse下的map-reduce运行环境 1

    1.通过修改实例模板程序来实现自己的map-reduce: 为了让示例程序run起来: 1)安装eclipse 2)安装map-reduce的eclipse插件 eclipse的map-reduce插 ...

  8. 【转】Github轻松上手5-站在巨人的肩膀上(Fork)

    转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzj3.html 有时候你可能想给别人的项目出把力,或者想以别人的项目作为自己项目的起点,在Github里 ...

  9. Android RecyclerView使用详解(二)

    在上一篇(RecyclerView使用详解(一))文章中简单的介绍了RecyclerView的基本用法,接下来要来讲讲RecyclerView的更多用法,要实现不同的功能效果,大部分都还是在于Recy ...

  10. 大数据分析的众包平台—Kaggle

    众包(Jeff Howe,2006)是一种在互联网蓬勃发展的背景下产生的一种创新的生产组织形式.在这样的商业模式下,企业利用网络将工作分配出去,通过让更合适的人群参与其中来发现创意和解决技术问题.比较 ...