题先附上:水题,可是思路不正确,特easy超时(TLE)

The shortest problem

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

Total Submission(s): 1084    Accepted Submission(s): 534

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
 

自己写的过程:

连交几发都是超时。超内存;

做题一定要注意:思路清晰。思维迅速敏捷。

想好再写代码,不要还没思路就动手敲。什么也敲不出来。

自己又写了一遍AC了
同一时候。在看他的代码时学到了另外的一些东西。
自己做题时的模版基本上写每道题时,套的库呀,另一些经常使用的宏定义,以及一些常量。自己都能够做成属于自己的模版。

以后再写题时,就不用每次都敲一遍了。




这道题的代码:

#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; int n;
long t; int main()
{
long js,os,i,j=0,k,m,p,q;
while(cin>>n>>t){
if(n==-1&&t==-1)break;
j++;
js=n%10+(n/100)%10+(n/10000)%10;
os=(n/10)%10+(n/1000)%10;
for(i=1;i<=t;i++){
k=p=q=0;
m=js+os;
while(m){
k++;
if(k%2)p+=m%10;
else q+=m%10;
m/=10;
}
if(k%2){
js+=q;
os+=p;
swap(js,os);
}
else {
js+=p;
os+=q;
}
}
if((js-os)%11)cout<<"Case #"<<j<<": No"<<endl;
else cout<<"Case #"<<j<<": Yes"<<endl;
}
return 0;
}

hdu5373的更多相关文章

  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. 2015 多校联赛 ——HDU5373(模拟)

    Problem Description In this problem, we should solve an interesting game. At first, we have an integ ...

  3. HDU5373 The shortest problem (YY)

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

  4. [hdu5373 The shortest problem]模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=5373 思路:按题意来即可. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

随机推荐

  1. spring boot配置

    spring.application.name=XXXXXserver.port=9515 # health显示down的问题endpoints.health.sensitive= falsemana ...

  2. C# 数组 之间转换

    List<string> strLen = new List<string>();            if (!string.IsNullOrEmpty(group_id) ...

  3. PHP协程是通过生成器实现的,这里测试了PHP生成器的一些特性

    学习PHP的生成器,测试了一些特性.代码如下: function gen() { $name = (yield 'hello'); $nickname = (yield 'world'); yield ...

  4. Jeddict目前的使用现状

    一.为什么使用jeddict 工具:提升生产力的工具:创建并部署一个CRUD服务系统,只需要5-10分钟 规范:生成的代码,都是稳定可执行代码(前端自动使用selenium框架测试,后端使用Arqui ...

  5. layui.code代码装饰器

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  6. POJ——1308Is It A Tree?(模拟拓扑排序判断有向图是否为树)

    Is It A Tree? Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28399   Accepted: 9684 De ...

  7. 百度网络监控实战:NetRadar横空出世(下)

    原文:https://mp.weixin.qq.com/s/CvCs-6rX8Lb5vSTSjYQaBg 转自订阅号「AIOps智能运维」,已授权运维帮转发 作者简介:运小贝,百度高级研发工程师 负责 ...

  8. bzoj 1196 公路修建问题

    bzoj 1196: [HNOI2006]公路修建问题 Description OI island是一个非常漂亮的岛屿,自开发以来,到这儿来旅游的人很多.然而,由于该岛屿刚刚开发不久,所以那里的交通情 ...

  9. linux内核设计与实现第一章

    1.1 unix的历史 Thompson实现unix 伯克利大学对其进一步开发推出了著名的BSD 其他各大厂商相继推出自己的unix 1.1.2 unix的特性 unix系统是一个强大,健壮,稳定的操 ...

  10. CodeForces 141E: ...(最小生成树)

    [条件转换] 两两之间有且只有一条简单路径<==>树 题意:一个图中有两种边,求一棵生成树,使得这棵树中的两种边数量相等. 思路: 可以证明,当边的权是0或1时,可以生成最小生成树到最大生 ...