整理代码。。。

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. Tricky Sum

    In this problem you are to calculate the sum of all integers from 1 to n, but you should take all po ...

  2. SXCPC2018 nucoj2005 大闹上兰帝国

    超 dark van♂全背包 ref1 ref2 #include <iostream> #include <cstring> #include <cstdio> ...

  3. hdu3366 Count the string

    考虑dp[i]代表前缀s[1...i]出现的次数,必定有dp[nxt[i]] += dp[i] 倒着推就是了 #include <iostream> #include <cstrin ...

  4. IOS开发学习笔记034-UIScrollView-xib实现分页

    通过xib实现分页功能的封装 1.首先实现xib UIView 的尺寸为300*130,因为准备的图片为600*260. scrollView属性设置如下: 2.新建一个和xib同名的类 2.1 类方 ...

  5. sql语句查询数据库案例

    package com.hanqi.test; import java.sql.Connection; import java.sql.PreparedStatement; import java.s ...

  6. 查看2个Python字典的相同以及不同之处

    a = { "x":1, "y":2, "z":3 } b = { "x":1, "w":11, & ...

  7. php 不重新编译增加openssl扩展

    安装openssl和开发包 yum install openssl openssl-devel 跳转到PHP源码下的openssl cd /usr/local/src/php-5.5.27/ext/o ...

  8. Log4j官方文档翻译(四、如何在java中输出日志消息)

    我们已经创建来配置文件,本章详细的介绍下如何生成调试信息,并把他们转化成文本文件. 基本的例子 下面就是创建的一个基本的例子: log4j.properties的内容为: log = /usr/hom ...

  9. 【bzoj3924】[Zjoi2015]幻想乡战略游戏 动态点分治

    题目描述 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做越大,以至于幽香一眼根本看不过来,更别说和别人打 ...

  10. P4302 [SCOI2003]字符串折叠

    题目描述 折叠的定义如下: 一个字符串可以看成它自身的折叠.记作S = S X(S)是X(X>1)个S连接在一起的串的折叠.记作X(S) = SSSS…S(X个S). 如果A = A’, B = ...