题先附上:水题,可是思路不正确,特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. python 学习分享-购物车实操篇

    程序要求如下: '''购物车程序: 启动程序后,输入用户名密码后,如果是第一次登录,让用户输入工资,然后打印商品列表 允许用户根据商品编号购买商品 用户选择商品后,检测余额是否够,够就直接扣款,不够就 ...

  2. Wireshark 安装及开始抓包中出现的问题

    前两天装了Wireshark,这次安装遇到了之前没遇到的问题,所以就写出来大家参考下 安装Wireshark时需要安装集成在安装包中的winpcap[winpcap(windows packet ca ...

  3. [luoguP2336] [SCOI2012]喵星球上的点名(后缀数组 + 暴力)

    传送门 原本的想法是把所有的串不管是名字还是询问都连起来,记录一下询问串在sa数组中的位置 对于每个询问可以在sa数组中二分出左右边界,第一问用莫队,第二问差分乱搞. 结果发现我差分的思路想错了,先写 ...

  4. SJTU Summer Camp

    Day -2,-1 提前坐飞机来到了上海,在旁边的酒店住下来,晚上去了外滩,在黄浦江边吹着晚风,依旧感慨万千,在衡中高三的一年竟然已经过去,经常出现在噩梦中的高考也已成为历史,然而命运可能并未就此改变 ...

  5. eval()函数的巧用

    eval的功能 将字符串str当成有效的表达式来执行.. 写函数,专门计算图形的面积 其中嵌套函数,计算圆的面积,正方形的面积和长方形的面积 调用函数area(‘圆形’,圆半径)  返回圆的面积 调用 ...

  6. 利用node搭建本地服务器调试代码

    在命令符中输入 npm install -g live-server安装live-server 安装完成后在项目文件夹下打开cmd,输入live-server启动

  7. 滑雪与时间胶囊(bzoj 2753)

    Description a180285非常喜欢滑雪.他来到一座雪山,这里分布着M条供滑行的轨道和N个轨道之间的交点(同时也是景点),而且每个景点都有一编号i(1<=i<=N)和一高度Hi. ...

  8. 【CF1027B】Numbers on the Chessboard(数学)

    题意:给定一个n*n的矩阵与生成矩阵的方式,多次询问同一个方格内(x,y)的数字是多少 题意:浪费人生的矩阵题,找规律 #include<cstdio> #include<cstri ...

  9. Ubuntu 16.04 LTS 成功编译 Android 6.0 源码教程

    sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386 \  libx11-dev:i386 ...

  10. AC日记——太空飞行计划 洛谷 P2762

    题目背景 题目描述 W 教授正在为国家航天中心计划一系列的太空飞行.每次太空飞行可进行一系列商业性实验而获取利润.现已确定了一个可供选择的实验集合E={E1,E2,…,Em},和进行这些实验需要使用的 ...