The shortest problem

Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 969 Accepted Submission(s): 491

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

Source

2015 Multi-University Training Contest 7

比赛的时候别人直接暴力就可以过,我们为什么过不了QAQ

#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std; const int INF =0x3f3f3f3f; int k; int a[52]; int aa(int m)
{
int sum=0;
k=0;
while(m)
{
sum+=m%10;
a[k++]=m%10;
m/=10; }
return sum;
} int main()
{
int n,m;
int sum;
int w=1;
int ans;
while(scanf("%d %d",&n,&m))
{
if(n==-1&&m==-1)
{
break;
}
if(n==0)
{
printf("Case #%d: Yes\n",w++);
continue;
}
sum=aa(n);
ans=0;
int v=1;
while(k--)
{
if(v)
{
ans+=a[k];
v=0;
}
else
{
ans-=a[k];
v=1;
}
}
while(m--)
{
sum+=aa(sum);
while(k--)
{
if(v)
{
ans+=a[k];
v=0;
}
else
{
ans-=a[k];
v=1;
} }
}
if(ans<0)
{
ans=-ans;
}
if(ans%11)
{
printf("Case #%d: No\n",w++);
}
else
{
printf("Case #%d: Yes\n",w++);
}
}
return 0;
}

The shortest problem的更多相关文章

  1. HDU-5373 The shortest problem

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

  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. 同余模定理 HDOJ 5373 The shortest problem

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

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

  5. The shortest problem(hdu,多校

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

  6. hdoj 5373 The shortest problem

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

  7. HDU5373 The shortest problem (YY)

    http://acm.hdu.edu.cn/showproblem.php?pid=5373 YY题,模拟下计算过程就好了,计算中并不要保存实际数(这个数会非常大),只要保存到目前为止的数字位上的和 ...

  8. (能被11整除的数的特征)The shortest problem --hdu

    链接: http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=595 若一个整数的个位数字截去,再从余下的数中 ...

  9. HDU 5373 The shortest problem (数学)

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

随机推荐

  1. 比较Date时间先后

    if ([firstDetailSelect compare:secondDetailSelect] == NSOrderedDescending) { [MBProgressHUD showErro ...

  2. 模拟退火法(吊打XXX)Bzoj3680

    3680: 吊打XXX Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special Judge Submit: 308  Solved: 94 [Subm ...

  3. 20145207 《Java程序设计》第一周学习总结

    不好意思,来晚了   别的先不说,先道个歉,放假前跟娄老师多少发生点矛盾,望原谅. 假期忙实习还有一些其他事情,为了认真对待这门课,把剩下的时间留下来,争取一天一章来弥补. 由于没选课加上另一门课没开 ...

  4. ligerui_ligerTree_001_第一个“树”效果

    折叠.展开.有复选框.没有复选框: 源码地址:http://download.csdn.net/detail/poiuy1991719/8571255 效果图: <%@ page languag ...

  5. android复习第一天-----简单的android常识

    前言:要去面试了,这些天花一些事件把android中简单的知识点来串联的复习一下 1,android中的工程结构 src文件夹:存储android文件的源代码 gen文件夹:有工具自动生成,不要去修改 ...

  6. 在C#中使用LOG4NET(winform程序

    http://www.csharpwin.com/csharpspace/678.shtml 1.下载log4net (Google log4net) 2.unzip log4net 3.运行VS,新 ...

  7. hadoop 启动停止命令

    1       批量启动与停止 1.1  Start-all.sh # Start all hadoop daemons.  Run this on master node. bin=`dirname ...

  8. 什么是商业智能BI和实施BI的解决方案【转】

    商业智能,或BI,是一种统称,泛指用于对一个企业的原始数据进行分析的各种各样的软件系统.商业智能(BI)是由若干相关的活动组成的领域,包括数据挖掘,在线分析处理,查询和报表. 企业用商业智能(BI)来 ...

  9. PHP开发框架Laravel优点,Laravel5.3中文文档

    PHP开发框架Laravel优点 Laravel的设计思想是很先进的,非常适合应用各种开发模式TDD, DDD和BDD,作为一个框架,它为你准备好了一切,composer是个php的未来,没有comp ...

  10. 将edit ctrL弄的像个dos

    case WM_CTLCOLOREDIT: { HWND hShellText = GetDlgItem(hDlg,IDC_TXT_SHELL); if (hShellText == (HWND)lP ...