整理代码。。。

Little Boxes

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2304    Accepted Submission(s): 818

Problem Description
Little boxes on the hillside.
Little boxes made of ticky-tacky.
Little boxes.
Little boxes.
Little boxes all the same.
There are a green boxes, and b pink boxes.
And c blue boxes and d yellow boxes.
And they are all made out of ticky-tacky.
And they all look just the same.
 
Input
The input has several test cases. The first line contains the integer t (1 ≤ t ≤ 10) which is the total number of test cases.
For each test case, a line contains four non-negative integers a, b, c and d where a, b, c, d ≤ 2^62, indicating the numbers of green boxes, pink boxes, blue boxes and yellow boxes.
 
Output
For each test case, output a line with the total number of boxes.
 
Sample Input
4
1 2 3 4
0 0 0 0
1 0 0 0
111 222 333 404
 
Sample Output
10
0
1
1070
 
Source
 

水题

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int maxn=;
const int mod=1e9+;
const int inf=0x3f3f3f3f;
const double eps=acos(-1.0);
int a[maxn],b[maxn],c[maxn],d[maxn];
int main(int argc,const char *argv[]){
string str1,str2,str3,str4;
int len1,len2,len3,len4;
int up,n;
cin>>n;
while(n--){
cin>>str1>>str2>>str3>>str4;
len1=str1.length();len2=str2.length();
len3=str3.length();len4=str4.length();
memset(a,,sizeof(a));memset(b,,sizeof(b));
int i,j,k;
for(i=len1-,k=;i!=-;--i){
a[k]=str1[i]-'';
k++;
}
for(j=len2-,k=;j!=-;--j){
b[k]=str2[j]-'';
k++;
}
for(i=,up=;i<;++i){
a[i]=a[i]+b[i]+up;
up=a[i]/;
a[i]%=;
}
memset(b,,sizeof(b));memset(c,,sizeof(c));
for(i=len3-,k=;i!=-;--i){
b[k]=str3[i]-'';
k++;
}
for(j=len4-,k=;j!=-;--j){
c[k]=str4[j]-'';
k++;
}
for(int i=,up=;i<maxn;++i){
b[i]=b[i]+c[i]+up;
up=b[i]/;
b[i]%=;
}
for(i=,up=;i<maxn;++i){
a[i]=a[i]+b[i]+up;
up=a[i]/;
a[i]%=;
}
for(i=maxn-;i>=;i--){
if(a[i])break;
}
if(i==-)
cout<<"";
else
for(;i>=;i--)
cout<<a[i];
cout<<endl;
}
return ;
}

HDU 6225.Little Boxes-大数加法 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))的更多相关文章

  1. HDU 6227.Rabbits-规律 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))

    Rabbits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  2. 2017ACM/ICPC亚洲区沈阳站-重现赛

    HDU 6222 Heron and His Triangle 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6222 思路: 打表找规律+大数运算 首先我 ...

  3. 2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)

    Little Boxes Problem Description Little boxes on the hillside.Little boxes made of ticky-tacky.Littl ...

  4. hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)

    废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: ...

  5. 2016ACM/ICPC亚洲区沈阳站-重现赛赛题

    今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...

  6. 2016ACM/ICPC亚洲区沈阳站-重现赛

    C.Recursive sequence 求ans(x),ans(1)=a,ans(2)=b,ans(n)=ans(n-2)*2+ans(n-1)+n^4 如果直接就去解...很难,毕竟不是那种可以直 ...

  7. 2015ACM/ICPC亚洲区沈阳站重现赛-HDU5512-Pagodas-gcd

    n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, l ...

  8. 2015ACM/ICPC亚洲区沈阳站-重现赛 M - Meeting (特殊建边,最短路)

    题意:有\(n\)个点,\(m\)个集合,集合\(E_i\)中的点都与集合中的其它点有一条边权为\(t_i\)的边,现在问第\(1\)个点和第\(n\)个点到某个点的路径最短,输出最短路径和目标点,如 ...

  9. 2015ACM/ICPC亚洲区沈阳站-重现赛 B - Bazinga (KMP)

    题意:给你\(n\)个字符串,\(s_1,s_2,...,s_n\),对于\(i(1\le i\le n)\),找到最大的\(i\),并且满足\(s_j(1\le j<i)\)不是\(s_i\) ...

随机推荐

  1. printf("\033[1;33m ***** \033[0m \n");

    printf("\033[1;33m Hello World. \033[0m \n"); 颜色如下: none = "\033[0m" black = &qu ...

  2. Codeforces Round #460 (Div. 2)-B. Perfect Number

    B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Descriptio ...

  3. BFS:Nightmare(可返回路径)

    解题心得: 1.point:关于可以返回路径的BFS的标记方法,并非是简单的0-1,而是可以用时间比较之后判断是否push. 2.queue创建的地点(初始化问题),在全局中创建queue在一次调用B ...

  4. VS2010Datatable查看器查看超时(Microsoft.VisualStudio.DebuggerVisualizers)

    这个问题由来已久,却一直没有找到原因.大家都知道,VisualStudio的DebuggerVisualizers是一个非常方便的插件,可以帮助我们调试时查看Datatable视图,前阵子突然发现在查 ...

  5. ActiveMQ初步学习

    本文主要参考张丰哲大神的简书文章,链接 https://www.jianshu.com/p/ecdc6eab554c JMS,即Java Message Service,通过面向消息中间件(MOM:M ...

  6. Codeforces 1139D(期望dp)

    题意是模拟一个循环,一开始有一个空序列,之后每次循环: 1.从1到m中随机选出一个数字添加进去,每个数字被选的概率相同. 2.检查这个序列的gcd是否为1,如果为1则停止,若否则重复1操作直至gcd为 ...

  7. maven学习(六)——在别的项目中引用通过Maven安装生成的项目的jar包

    1.新建HelloFriend项目,同时建立Maven约定的目录结构和pom.xml文件 HelloFriend    | --src | -----main | ----------java | - ...

  8. PAT A+B格式

    A + B格式(20) 时间限制 400毫秒 内存限制 65536 kB 代码长度限制 16000 B. 判断程序 标准 作者 陈,岳 计算a + b并以标准格式输出总和 - 即数字必须用逗号分隔成三 ...

  9. 【转】ugui自制摇杆

    http://www.cnblogs.com/duyushuang/p/4457691.html 珍爱生命,远离插件. 以上8个字,好好理解. 反正我是这么觉得. 我说的是unity,不是魔兽世界. ...

  10. Lyft Level 5 Challenge 2018-Final Round(Open Div.2) B. Taxi drivers and Lyft

    http://codeforces.com/contest/1075/problem/B Palo Alto is an unusual city because it is an endless c ...