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. 【转】轻量级分布式 RPC 框架

    第一步:编写服务接口 第二步:编写服务接口的实现类 第三步:配置服务端 第四步:启动服务器并发布服务 第五步:实现服务注册 第六步:实现 RPC 服务器 第七步:配置客户端 第八步:实现服务发现 第九 ...

  2. 【转】DataSource高级应用

    我们知道 DataSource能提供最高性能的对数据库的并发访问,但是,对DataSource的引用,也还有很多知识要弄清楚,获取Connection的方式是数据库性能最相关的技术,而对DataSou ...

  3. Compile Sources 和 Copy Bundle Resources的区别

    Compile Sources主要存放.m文件 Copy Bundle Resources 主要存放xib plist bundle js 文件

  4. Dictionary中的结构体转出来

    CGRect keyBoardFrame = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

  5. 河南省第八届ACM程序设计大赛总结

    简单的对这次省赛做个总结:总体来说这个比赛过程中做的还算比较顺利,虽然中间多多少少遇到一些坑,正式比赛开始后,我们就开始找水题,当然了我首先把英文题目翻译了一遍,发现了一道水题,这道题目其实就是判断点 ...

  6. ASP.NET的一般处理程序对数据的基本操作

    TableList.ashx: <%@ WebHandler Language="C#" Class="TableList" %> using Sy ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  8. springday05-go1

    新建web工程spring-netcross1.导入spring文件夹里的七个jar包,另外还要导入jdbc-lib的四个jar包,ojdbc.jar,commoms-pool,commons-dbc ...

  9. 某个系统配置文件 用户层的SQL

    SELECT fpo.user_profile_option_name, fpv.level_id, fpv.level_value, fpv.profile_option_value, fu.use ...

  10. 夺命雷公狗—angularjs—11—service的基本概念

    我们先来研究下service里面的四大服务.. value 变量 constant  常量 factory   工厂模式 service 服务 <!DOCTYPE html> <ht ...