HDU 6225.Little Boxes-大数加法 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))
整理代码。。。
Little Boxes
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2304 Accepted Submission(s): 818
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.
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.
水题
代码:
#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亚洲区沈阳站-重现赛(感谢东北大学))的更多相关文章
- HDU 6227.Rabbits-规律 (2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学))
Rabbits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- 2017ACM/ICPC亚洲区沈阳站-重现赛
HDU 6222 Heron and His Triangle 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6222 思路: 打表找规律+大数运算 首先我 ...
- 2017ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
Little Boxes Problem Description Little boxes on the hillside.Little boxes made of ticky-tacky.Littl ...
- hdu 5510 Bazinga (kmp+dfs剪枝) 2015ACM/ICPC亚洲区沈阳站-重现赛(感谢东北大学)
废话: 这道题很是花了我一番功夫.首先,我不会kmp算法,还专门学了一下这个算法.其次,即使会用kmp,但是如果暴力枚举的话,还是毫无疑问会爆掉.因此在dfs的基础上加上两次剪枝解决了这道题. 题意: ...
- 2016ACM/ICPC亚洲区沈阳站-重现赛赛题
今天做的沈阳站重现赛,自己还是太水,只做出两道签到题,另外两道看懂题意了,但是也没能做出来. 1. Thickest Burger Time Limit: 2000/1000 MS (Java/Oth ...
- 2016ACM/ICPC亚洲区沈阳站-重现赛
C.Recursive sequence 求ans(x),ans(1)=a,ans(2)=b,ans(n)=ans(n-2)*2+ans(n-1)+n^4 如果直接就去解...很难,毕竟不是那种可以直 ...
- 2015ACM/ICPC亚洲区沈阳站重现赛-HDU5512-Pagodas-gcd
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, l ...
- 2015ACM/ICPC亚洲区沈阳站-重现赛 M - Meeting (特殊建边,最短路)
题意:有\(n\)个点,\(m\)个集合,集合\(E_i\)中的点都与集合中的其它点有一条边权为\(t_i\)的边,现在问第\(1\)个点和第\(n\)个点到某个点的路径最短,输出最短路径和目标点,如 ...
- 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\) ...
随机推荐
- Linux 内核源码外编译 linux模块--编译驱动模块的基本方法
1.先编写一个简单的hello模块,hello.c 源码如下: #ifndef __KERNEL__ # define __KERNEL__ #endif #ifndef MODULE # defin ...
- LeetCode刷题感想
断断续续用了半年的时间把LeetCode刷完了,之前复习了数据结构与算法.将刷题与复习数据结构结合起来会更有效果.总之不是为了刷题而刷题,而是为了巩固和补充一部分知识. LeetCode真的是一个很好 ...
- Linux命令之---cp/scp
命令简介 cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一.一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不管你是否使用-i参数. ...
- eeeeeeeeeee
http://58.241.123.38/hot.cdn.baidupcs.com/file/91623e76f776475da9c3223cdac861f0?xcode=68983c005f6e3c ...
- React基础(Diff算法,属性和状态)
1.React的背景原理 (1)React Diff算法流程 (2)React虚拟DOM机制 React引入了虚拟DOM(Virtual DOM)的机制:在浏览器端用Javascript实现了一套DO ...
- 倍增 - 强制在线的LCA
LCA 描述 给一棵有根树,以及一些询问,每次询问树上的 2 个节点 A.B,求它们的最近公共祖先. !强制在线! 输入 第一行一个整数 N. 接下来 N 个数,第 i 个数 F i 表示 i 的父亲 ...
- 设计模式之第5章-解释器模式(Java实现)
设计模式之第5章-解释器模式(Java实现) “开个商店好麻烦,做个收单的系统,发现类的方法好多.”“真是的,不就是简单的四则运算,这都不会!”你说你会啊.来来来,你把以下的方法用代码写出来: a+b ...
- [netty4][netty-transpot]Channel体系分析
Channel体系分析 接口与类结构体系 -- [I]AttributeMap, ChannelOutboundInvoker, Comparable -- [I]AttributeMap ---- ...
- stdlib.h中自带的两个算法qsort,bsearch
http://zh.cppreference.com/w/c/algorithm ========== void qsort( void *ptr, size_t count, size_t size ...
- VS 2013插件
http://www.spersky.com/post/vsPlugins.html http://vswebessentials.com/download http://developer.51ct ...