POJ 1503 大整数相加的问题
来源:互联网 发布:网络运行情况通报 编辑:程序博客网 时间:2024/05/22 15:24
开数组时,要开一个大数组,不然不通过。题意不明确,尼玛死,害老子在图书馆坐了一整天。。。
Integer Inquiry
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 26461 Accepted: 10258
Description
One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)
Input
The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).
The final input line will contain a single zero on a line by itself.
The final input line will contain a single zero on a line by itself.
Output
Your program should output the sum of the VeryLongIntegers given in the input.
Sample Input
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670
Source
East Central North America 1996
#include<stdio.h>#include<string.h>int main(){char a[1000],b[1000],c[1010],d[1010];int m,n,r,i=0,p=0,s=0,count=1;gets(a); gets(b);for(;i<1010;i++)d[i]='0';n=strlen(b);for(i=n-1;i>=0;i--){d[p]=b[i];p++; }while(count<100){if(count!=1)gets(a);if(!strcmp(a,"0"))break;for(i=0;i<1010;i++)c[i]='0';m=strlen(a);p=0;for(i=m-1;i>=0;i--){c[p]=a[i];p++;}for(i=0;i<1010;i++){r=c[i]+d[i]+s-96;s=r/10; d[i]=r%10+48;}count++;} for(i=1009;d[i]=='0';i--);for(;i>=0;i--)printf("%d",d[i]-'0');printf("\n");return 0;}
- POJ 1503 大整数相加的问题
- POJ 1503 Integer Inquiry 美丽的大整数相加 + 测试数据
- 大整数相加问题
- 两个大的整数相加
- poj之2981大整数相加
- C++解决大整数相加问题
- MySQL实现大整数相加的udf
- hdoj1047 Integer Inquiry(大整数的相加)
- 大整数相加算法
- 大整数相加
- 大整数相加
- 大整数相加
- 大整数相加
- 大整数相加
- 大整数相加
- 两个大整数相加
- 大整数相加
- 大整数相加
- 最大公约数,最小公倍数求解
- 二分查找
- Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
- Graphviz_User_Log01
- fedora下安装thrift
- POJ 1503 大整数相加的问题
- HTML5有意思的实现
- Android UI 使用更快更高效
- 二分查找法
- poj 1699(2013@USC D题)
- “Windows XP下vs2010中配置OpenCV2.4.3 ”的补充
- tiny6410开机自启动QT4程序,并设置程序为全屏显示
- jsp原理笔记(四)
- jsp标签自动提示,提高编程效率,自动提示