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. Make和Makefile

    无论是在Linux还是在Unix环境中,make都是一个非常重要的编译命令.不管是自己进行项目开发还是安装应用软件,我们都经常要用到make或make install.利用make工具,我们可以将大型 ...

  2. C#与.NET

    1 .NET Framework的核心是其运行库执行环境,即公共语言运行库(CLR)或.NET运行库,一般将CLR控制下运行的代码称为托管代码(managed code). 在CLR在执行编写好的代码 ...

  3. UniqueID,页面子控件唯一标示

    aspx: <form id="form1" runat="server">     <asp :Repeater ID="MyDa ...

  4. Demo学习: CalendarPanel

    CalendarPane 学习CalendarPanel控件的常用事件. DayClick(...) //点击日期块空白部分触发EventClick(...) //点击日期块上事件触发RangeSel ...

  5. 转:testlink 环境搭建(傻瓜版)

    testlink 环境搭建(傻瓜版) 2011-11-24 22:23 by 虫师, 12322 阅读, 4 评论, 收藏, 编辑 今天抽了点时间把testlink 环境搭建了一下,一直觉得这东西不怎 ...

  6. can't add foreign key in mysql?

    create table department (dept_name ), building ), budget numeric(,) ), primary key (dept_name) ); cr ...

  7. Windows操作系统常用快捷键

    复制:ctrl+c       剪切:ctrl+x      粘贴:ctrl+v       全选:ctrl+a         撤消:ctrl+z      保存:ctrl+s 运行:win+r   ...

  8. SDC(7) -- 关于使能信号的时序放松

    先看下图: 假如使能信号的有效时间为时钟周期的2倍,此时需要使用 set_multicycle_path 放松使能信号 sel_xy_nab ,若是每个寄存器使能端都约束一遍,那就太麻烦了: 这时可以 ...

  9. JVM里面hashtable和hashmap实现原理

    JVM里面hashtable和hashmap实现原理   文章分类:Java编程 转载 在hashtable和hashmap是java里面常见的容器类, 是Java.uitl包下面的类, 那么Hash ...

  10. linux 安装Tesseract-OCR

    linux 安装Tesseract-OCR 准备工作:一.编译环境: 1. gcc gcc-c++ make(这个环境一般机器都具备,可以忽略) yum install gcc gcc-c++ mak ...