整理代码。。。

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. ubuntu 把软件源修改为国内源和更新(转载)

    1. 备份原始文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup 2. 修改文件并添加国内源 vi /etc/apt/sourc ...

  2. unity安装记录

    官网直接下载(http://unity3d.com/cn/) 下载完后,会要求输入账号密码.我是先在官网进行一个账号注册,然后登陆即可. 首先会要你输入一个已有的邮箱,进行认证.进入自己邮箱,点击链接 ...

  3. Django Rest Framework threoy

    rest_framework源码分析: 1.as_view() 2.父类的as_view() view = super(APIView, cls).as_view(**initkwargs) 3.vi ...

  4. Android输入法弹出时覆盖输入框问题

    本文来自网易云社区 作者:孙有军 当一个activity中含有输入框时,我们点击输入框,会弹出输入法界面,整个界面的变化效果与manifest中对应设置的android:windowSoftInput ...

  5. leetcode 【 Rotate Image 】python 实现

    题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwis ...

  6. ADO之密码验证--3次错误就锁定『改进』

    这里使用了SqlHelper,简化程序 自己写一个SqlHelper,把数据库的连接等都写到里面去. 首先把连接字符串添加到配置文件里去,右键解决方案-->添加新建项-->选择应用程序配置 ...

  7. aircrack-ng破解wlan无线流量包

    记录一下新的知识点. 无线协议里最关键的就是EAPOL协议了,这个里面保存着密钥,所以破解无线流量包也应该从这里入手. 用到的工具是aircrack-ng,这个在kali自带,也可以下载windows ...

  8. CMD 下运行python的unittest测试脚本无输出

    正常情况下windows的命令行执行python脚本命令: python 脚本名.py 我这样做了,看截图可以看到,并没有期待中那样有一堆高大上的信息输出,反而毛都没有!!!! 于是,我想起了度娘,但 ...

  9. 【LeetCode】Merge Sorted Array(合并两个有序数组)

    这道题是LeetCode里的第88道题. 题目描述: 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组. 说明: 初始化 nu ...

  10. TextBox的值随dropdownlist值而变化

    转自:http://bytes.com/topic/asp-net/answers/443065-textbox-value-change-select-other-item-dropdownlist ...