整理代码。。。

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. 从0到n-1中随机等概率输出m个不同的数

    //假设输入的n远大于m void knuth(int n, int m) { for (int i = 0; i < n; i++) { if (rand() % (n - i)<m) ...

  2. POJ 2311 Cutting Game(SG函数)

    Cutting Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4806   Accepted: 1760 Desc ...

  3. laravel5.2总结--关联关系

     参考文章 http://laravelacademy.org/post/1095.html http://laravelacademy.org/post/1174.html http://d.lar ...

  4. VC下如何调用控制台命令以及其他可执行文件

    开始的时候想写一个基于MFC的Wifi开关控制程序,可是不知道VC中如何调用控制台命令,经过网上的学习,发现其实挺挺简单也挺好用.于是制作了一个简单的基于MFC个人助理小软件,可以点击按钮实现Wifi ...

  5. CSS滚动插件

    http://www.dowebok.com/131.html  wow.js http://www.jq22.com/jquery-info499 smoove.js http://www.lanr ...

  6. 使用 Anime 类在 XNA 中创建小动画(十一)

    平方已经开发了一些 Windows Phone 上的一些游戏,算不上什么技术大牛.在这里分享一下经验,仅为了和各位朋友交流经验.平方会逐步将自己编写的类上传到托管项目中,没有什么好名字,就叫 WPXN ...

  7. Vue声明渲染以及axios实例

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  8. 零基础学习 Python 之字符串

    初识字符串 维基百科对于字符串的定义式:字符串是由零个或者多个字符组成的有限串行.你之前学会敲的第一行 print 代码里的 "Hello World",就是一个字符串.字符串的本 ...

  9. Hadoop第三课

    1.3Hadoop基础知识 1.3.1术语解释 1.Hadoop1.0 • 第一代Hadoop,由分布式文件系统HDFS 和分布式计算框架MapReduce组成 • HDFS由一个NameNode和多 ...

  10. Java开发微信公众号(二)---开启开发者模式,接入微信公众平台开发

    接入微信公众平台开发,开发者需要按照如下步骤完成: 1.填写服务器配置 2.验证服务器地址的有效性 3.依据接口文档实现业务逻辑 资料准备: 1.一个可以访问的外网,即80的访问端口,因为微信公众号接 ...