The shortest problem

http://acm.hdu.edu.cn/showproblem.php?pid=5373

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

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
 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <malloc.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define MAX 999999999
#define LL long long
#define M 6666666
using namespace std;
int main()
{
int n,m,i,j,k,l,cas=;
while(~scanf("%d%d",&n,&m))
{
if(n==-&&m==-)break;
if(m==)
{
if(n%==)printf("Case #%d: Yes\n",cas++);
else printf("Case #%d: No\n",cas++);
continue;
}
k=n;
l=;
while(k>)
{
l+=k%;
k/=;
}//cout<<l<<endl;
while(m--)
{
k=l;//cout<<l<<" ";
while(k>)
{
k/=;
n*=;
}
n=(n+l)%;
k=l;
while(k>)
{
l+=k%;
k/=;//cout<<l<<endl;
}
}
if(n==)printf("Case #%d: Yes\n",cas++);
else printf("Case #%d: No\n",cas++);
}
return ;
}
Source

HDU-5373 The shortest problem的更多相关文章

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

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

  2. 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 ...

  3. HDU 5373 The shortest problem (数学)

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

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

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

  5. hdoj 5373 The shortest problem

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5373 一开始想到用整除11的性质去做,即奇位数的和和偶位数的和的差为11的倍数,但估不准数据范围没敢去 ...

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

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

  7. The shortest problem(hdu,多校

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

  8. HDU 4725 The Shortest Path in Nya Graph [构造 + 最短路]

    HDU - 4725 The Shortest Path in Nya Graph http://acm.hdu.edu.cn/showproblem.php?pid=4725 This is a v ...

  9. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

随机推荐

  1. HTML5的离线储存

    在用户没有与因特网连接时,可以正常访问站点或应用,在用户与因特网连接时,更新用户机器上的缓存文件.        原理:HTML5的离线存储是基于一个新建的.appcache文件的缓存机制(不是存储技 ...

  2. Jquery ajax使用json形式通信

    前台JS $.ajax({                              type: 'post',                              url: 'HandlerL ...

  3. 使用Adobe Photoshop CC 2015批量修改图片尺寸

    最近在工作中遇到一个问题,当时客户给的图片尺寸与我要求的图片不符,由于图片非常的多,如果一张一张的修改,十分的麻烦,后来经过一位同事的指点,发现Adobe Photoshop CC 2015可以实现批 ...

  4. prefix和unprefix

    exports._esModule = true; exports.default = { prefix: function prefix(prop){ if (prop[0] === '-'){ v ...

  5. JSONP(跨域请求) —— 一种非官方跨域数据交互协议

    1.JSONP的作用 由于同源策略的限制,XmlHttpRequest只允许请求当前源(域名.协议.端口)的资源,为 了实现跨域请求,可以通过script标签实现跨域请求,然后再服务器端输出JSON数 ...

  6. 字符编码笔记:ASCII,Unicode和UTF-8【转载】

    作者: 阮一峰 日期: 2007年10月28日 今天中午,我突然想搞清楚Unicode和UTF-8之间的关系,于是就开始在网上查资料. 结果,这个问题比我想象的复杂,从午饭后一直看到晚上9点,才算初步 ...

  7. web2py--------------用web2py写 django的例子 --------开发环境

    我们先从广为人知的例子说起xi 也就是官方的例子,我会在最后给出代码: ============================环境=================== 编译器使用vs code , ...

  8. Oracle 插入数据

    6个柜面交易 打印修改--050101 delete from tran_prints where tran_id = (select id from tran where code='050101' ...

  9. userInteractionEnabled

    NO -------是自身View下面的按钮之类的能点 YES------是View自身的按钮能点击,他下面的不能点击

  10. MongoDB 配置文件启动

    MongoDB 服务启动有两种方式:一种是直接命令启动,一种是通过配置文件启动 1.命令启动: mongod -dbpath C:\data\db -logpath C:\data\log\mongo ...