hdu5373
题先附上:水题,可是思路不正确,特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
it for t times. When n=123 and t=3 then we can get 123->1236->123612->12361215.
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.
35 2
35 1
-1 -1
Case #1: Yes
Case #2: No
自己写的过程:
连交几发都是超时。超内存;
以后再写题时,就不用每次都敲一遍了。
这道题的代码:
#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的更多相关文章
- HDU-5373 The shortest problem
The shortest problem http://acm.hdu.edu.cn/showproblem.php?pid=5373 Time Limit: 3000/1500 MS (Java/O ...
- 2015 多校联赛 ——HDU5373(模拟)
Problem Description In this problem, we should solve an interesting game. At first, we have an integ ...
- HDU5373 The shortest problem (YY)
http://acm.hdu.edu.cn/showproblem.php?pid=5373 YY题,模拟下计算过程就好了,计算中并不要保存实际数(这个数会非常大),只要保存到目前为止的数字位上的和 ...
- [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 ...
随机推荐
- python - 函数的相互调用 及 变量的作用域
# -*- coding:utf-8 -*- '''@project: jiaxy@author: Jimmy@file: study_函数的相互调用及变量的作用域.py@ide: PyCharm C ...
- Bootstrap-table custome-ajax用法
<div id="toolbar"> <div class="form-inline" role="form"> & ...
- kb-01-a<简单搜索--dfs八皇后问题变种>
题目描述: 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的 ...
- [POI2007]MEG-Megalopolis (树状数组,Dfs序)
题目描述 Solution 这道题考试的时候竟然没有仔细想,结果只拿了暴力分... 其实就是一个 DFS序+树状数组. 我们先把用 DFS 把它变成一个序列,同时记录它们的 \(siz\). 那么我们 ...
- 外星人(bzoj 2749)
Description Input Output 输出test行,每行一个整数,表示答案. Sample Input 1 2 2 2 3 1 Sample Output 3 HINT Test< ...
- best corder MG loves gold
MG loves gold Accepts: 451 Submissions: 1382 Time Limit: 3000/1500 MS (Java/Others) Memory Limit ...
- 【HDU4372】Count the Buildings (第一类斯特林数)
Description $N$座高楼,高度均不同且为$1~N$中的数,从前向后看能看到$F$个,从后向前看能看到$B$个,问有多少种可能的排列数. $T$组询问,答案模$1000000007$.其中$ ...
- C# 获取当前目录上一级目录
string path="D:\AA\BB\CC"; Directory.SetCurrentDirectory(Directory.GetParent(path).FullNam ...
- sublime text3 cssrem 快速px转rem插件
今天试验了下cssrem 在移动端如果需要px->rem非常方便 比较之前我自己用gulp提供的函数unit(70/@base,rem);转方便很多 1.git clone https://g ...
- ListView更新方法的优化
ListView和Adapter对象均具备有对象更新方法 ListView对象列表的更新方法1.invalidate();--重绘组件2.invlidateView()--重绘组件并包含所有的View ...