# The shortest problem

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

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$10^4$ ) , t(0<=t<=105$10^5$) 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

n$n$ 的后面组成一个新的数，操作 t(t105)$t(t\le 10^5)$ 次，问 t$t$ 次之后的结果是不是能够被 11$11$

My Code$My\ Code：$

/**
2016 - 08 - 29 下午
Author: ITAK

Motto:

**/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
const double PI = acos(-1);
using namespace std;
LL Scan_LL()///输入外挂
{
LL res=0,ch,flag=0;
if((ch=getchar())=='-')
flag=1;
else if(ch>='0'&&ch<='9')
res=ch-'0';
while((ch=getchar())>='0'&&ch<='9')
res=res*10+ch-'0';
return flag?-res:res;
}
int Scan_Int()///输入外挂
{
int res=0,ch,flag=0;
if((ch=getchar())=='-')
flag=1;
else if(ch>='0'&&ch<='9')
res=ch-'0';
while((ch=getchar())>='0'&&ch<='9')
res=res*10+ch-'0';
return flag?-res:res;
}
void Out(LL a)///输出外挂
{
if(a>9)
Out(a/10);
putchar(a%10+'0');
}
int a[MAXN];
int main()
{
int t, cas = 1, n;
while(cin>>n>>t)
{
if(n==-1 && t==-1)
break;
int tmp = n, cnt = 1, sum = 0;
memset(a, 0, sizeof(a));
while(tmp)
{
a[cnt++] = tmp%10;
sum += (tmp%10);
tmp /= 10;
}
for(int i=1; i<=cnt/2; i++)
swap(a[i], a[cnt-i]);
int sum1 = 0, sum2 = 0, tp;
for(int i=1; i<cnt; i++)
{
if(i & 1)
sum1 += a[i];
else
sum2 += a[i];
}
///cout<<"sum1 = "<<sum1<<endl<<"sum2 = "<<sum2<<endl;
while(t--)
{
tmp = sum, tp = cnt;
///cout<<"sum = "<<sum<<endl;
while(tmp)
{
a[cnt++] = tmp%10;
sum += (tmp%10);
tmp /= 10;
}
for(int i=tp; i<=(cnt-1+tp)/2; i++)
swap(a[i], a[cnt-i+tp-1]);
/**for(int i=1; i<cnt; i++)
cout<<"a[i] = "<<a[i]<<endl;
cout<<"+++++++++++++++++++++++"<<endl;*/
for(int i=tp; i<cnt; i++)
{
if(i & 1)
sum1 += a[i];
else
sum2 += a[i];
}
}
///cout<<"sum1 = "<<sum1<<endl<<"sum2 = "<<sum2<<endl;
if(abs(sum1-sum2) % 11 == 0)
printf("Case #%d: Yes\n",cas++);
else
printf("Case #%d: No\n",cas++);
}
return 0;
}


#### HDU 5372 Segment Game(树状数组)——多校练习7

2015-08-12 16:25:56

#### HDU 3902 Swordsman 2011 Multi-University Training Contest 7 - Host by ECNU 计算几何

2011-08-04 00:50:56

#### 2016 Multi-University Training Contest 4 题解

2016-08-01 16:37:27

#### 2009 Multi-University Training Contest 8 - Host by BJNU

2016-11-06 15:28:27

#### HDU 3605 Escape 最大流or二分图多重匹配 2010 ACM-ICPC Multi-University Training Contest（17）——Host by ZSTU

2011-09-10 09:43:53

#### 2017 Multi-University Training Contest - Team 5

2017-08-08 19:47:48

#### 2013 Multi-University Training Contest 3 (g) The Unsolvable Problem

2013-09-19 15:00:25

#### 2017 Multi-University Training Contest - Team 9 E - FFF at Valentine

2017-08-22 18:12:55

#### 2015 Multi-University Training Contest 4

2015-07-30 16:41:18

#### HDU 5414 CRB and String( 2015 Multi-University Training Contest 10)

2015-09-01 11:08:35

## 不良信息举报

HDU 5373 The shortest problem（模拟）——2015 Multi-University Training Contest 7