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. 基于Jquery的banner轮播插件,简单粗暴

    新手练习封装插件,觉着在前端这一块的轮播比较多,各种旋转木马一类的3D旋转,技术不够,所以封装了一个简单的banner轮播插件,功能也比较简单,就是左右向的轮播. 先挂地址https://github ...

  2. nuget的使用总结

    使用NuGet发布自己的类库包(Library Package) from:http://blog.csdn.net/gulijiang2008/article/details/41724927 使用 ...

  3. python基础学习(二)--函数

    return返回值: python函数都有返回值,函数体内无return,默认返回值None, 函数参数: 1.普通参数 严格按照顺序,将实际参数赋值给形式参数,一一对应. 例: def send(x ...

  4. Python数据库连接池实例——PooledDB

    不用连接池的MySQL连接方法 import MySQLdbconn= MySQLdb.connect(host='localhost',user='root',passwd='pwd',db='my ...

  5. 转:jQuery.fn.extend与jQuery.extend到底区别在哪?

    还是先吐个槽,网上都都是转载抄袭,基本上就那么一两篇文章,说的还不清楚.... 正文: 其实说白了,从两个方法本身就能看出来端倪. 我们先把jQuery看成了一个类,这样好理解一些. jQuery.e ...

  6. 编译报错GLIBCXX_3.4.15 clock_gettime@@GLIBC_2.2

    GLIBCXX_3.4.15 升级gcc,g++编译器 clock_gettime@@GLIBC_2.2 链接库时加-lrt

  7. 几条特殊的SQL语句

    1, 有case情况. select trunc(exf_payment_receipt.work_date),exf_payment_receipt.exchange_code,exf_paymen ...

  8. JDBC和DBUtils区别(查询时jdbc只能返回ResultSet需要po转vo,dbutils返回的BeanListHandler与BeanHandler对应集合与对象)

    17:34 2013/6/7 JDBC //添加客户 public void addNewCustomer(Customer c) throws DAOException { Connection c ...

  9. centos7和windows7双系统安装

    前些天安装了双系统(centos7+win7),其实网上关于这类的教程很多,这篇日志也只是针对本人安装过程中遇到的一些问题进行说明.我是按照先安装win7再安装centos7的顺序. 1.关于分区: ...

  10. 日志分析-Web

    http://my.oschina.net/chenguang/blog/376267 http://my.oschina.net/chenguang/blog/371275 http://my.os ...