CSU - 1161 Sums
来源:互联网 发布:sql随机生成6位数字 编辑:程序博客网 时间:2024/05/22 00:10
题目:
Description
Sometimes Ziwen need to operate even larger numbers. A limit of 1000 digits is so small… You have to find the sum of two numbers with maximal size of 1 000 000 digits.
Input
The first line contains a single integer N that is the length of the given integers(1 ≤ N ≤ 1 000 000). It is followed by these integers written in columns. That is, the next N lines contain two digits each, divided by a space. Each of the two given integers is not less than 0, and the length of their sum does not exceed N. The integers may contain leading zeroes.
Output
Output exactly N digits in a single line representing the sum of these two integers.
Sample Input
40 44 26 83 7
Sample Output
4750
代码:
#include<iostream>using namespace std; int main(){ int n; cin >> n; int *list=new int[n]; int a; for(int i=0;i<n;i++) { cin>>a; list[i]=a; cin>>a; list[i]+=a; } for(int i=n-1;i>0;i--) { if(list[i]>9) { list[i]-=10; list[i-1]+=1; } } list[0] %=10; for(int i=0;i<n;i++)printf("%d",list[i]); return 0;}
1 0
- CSU - 1161 Sums
- Sums
- sums
- 51nod-1161 Partial Sums
- 51nod 1161 Partial Sums
- 51Nod-1161-Partial Sums
- 51nod 1161 Partial Sums
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- CSU
- 欢迎使用CSDN-markdown编辑器
- sspanel按月结算,修改go版代码【mysql api】
- Small Game
- Android截屏(fb0)
- 支持向量分类机---乳腺癌的诊断
- CSU - 1161 Sums
- NOIP2012 提高组 复赛 day1 game
- JVM——自定义类加载器
- 在Centos搭建Django测试环境
- 移动WEB开发框架
- C#入门10.2——接口的实现和继承(1)
- Python爬虫实战之爬取糗事百科段子
- AndroidStudio IDE主题不支持中文的解决办法
- 封锁阳光大学