HDU 1047 大数相加
来源:互联网 发布:mac上刀剑乱舞 编辑:程序博客网 时间:2024/06/10 09:09
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15694 Accepted Submission(s): 4027
``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.)
The final input line will contain a single zero on a line by itself.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
11234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
370370367037037036703703703670
反过来时顺便转成int。。。还有格式问题 还有就是a1每次都要初始化 否则影响接下来结果
#include<cstdio>#include<iostream>#include<cstring>#include<string>using namespace std;char s[1005];int a1[1005]={0};int a2[1005]={0};int main(){int n=0;scanf("%d",&n);getchar();while(n--){int k2=1;memset(s,0,sizeof(s));memset(a1,0,sizeof(a1));memset(a2,0,sizeof(a2));while(gets(s)){int len=strlen(s);int i=0,k1=0;if(s[0]=='0') break;for(i=len-1;i>=0;i--){a1[k1++]=s[i]-'0'; } int max=k1>k2?k1:k2; int k=0; int j=0; for(j=0;j<max;j++) { a2[j]=a2[j]+a1[j]+k; k=a2[j]/10; a2[j]%=10; } memset(a1,0,sizeof(a1)); if(k) { a2[j]=k; k2=j+1; } else { k2=j; }}for(int i=k2-1;i>=0;i--){printf("%d",a2[i]);}printf("\n"); if(n!=0) printf("\n");}return 0;}
- HDU 1047 大数相加
- HDU 1047 大数相加
- HDU 1047(大数相加)
- poj 1503 && hdu 1047 大数相加
- HDU 1047 || ZOJ 1292 大数相加
- HDU-1047 Integer Inquiry 大数相加
- HDU 1047。多个大数相加
- HDU ACM 1047 Integer Inquiry->大数相加
- HDU 1047(大数相加)(数组模拟)
- hdu 1002 大数相加
- HDU 1002(大数相加)
- HDU 1250(大数相加)
- hdu 1002大数相加
- HDU 2844 大数相加
- HDU-1002-大数相加
- hdu 1002 大数相加
- hdu 1002 大数相加
- hdu 2100 大数相加
- App Crash 解决办法
- 关于UIAutomator 滚动的steps
- common-logging和log4j切换到logback
- HDU 1004 Let the Balloon Rise(map)
- 为什么面试喜欢问算法问题
- HDU 1047 大数相加
- POST请求方式
- nginx(四)初识nginx日志文件
- hbase版本更新启动报错
- 实用Mac 快捷键大全
- 隐藏导航栏底部的那条线
- mysql 索引类型以及创建
- hdu 2112 HDU Today
- Android进阶网站分享(持续更新中……)