424 - Integer Inquiry
来源:互联网 发布:北京师范学校网络教育 编辑:程序博客网 时间:2024/06/10 14:50
424 - Integer Inquiry
Uva:
Integer Inquiry
Integer Inquiry
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.)
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.
Output
Your program should output the sum of the VeryLongIntegers given in the input.
Sample Input
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670Uva不允许c用//注释。
#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 100+10int main(){/* freopen("a.txt","r",stdin);*/ char s[N]; int num[N],i,j; memset(num,0,sizeof(num)); while(fgets(s,N,stdin)&&s[0]!='0') { int len=strlen(s)-2;/* printf("%d\n",len);*/ for(i=len,j=0;i>=0;i--,j++) { num[j]+=s[i]-'0'; if(num[j]>9) { num[j]-=10; num[j+1]+=1; } } } int f=0; for(i=N-1;i>=0;i--) { if(!f&&!num[i]) continue; f=1; printf("%d",num[i]); } putchar('\n'); return 0;}
- uva 424 - Integer Inquiry
- 424 - Integer Inquiry
- UVa 424 - Integer Inquiry
- 424 - Integer Inquiry
- UVa 424 - Integer Inquiry
- uva-424 - Integer Inquiry
- 424 - Integer Inquiry
- uva 424 - Integer Inquiry
- 424 - Integer Inquiry
- UVaOJ 424 - Integer Inquiry
- UVa 424 - Integer Inquiry
- UVA 424 Integer Inquiry
- UVa 424 - Integer Inquiry
- UVa 424 - Integer Inquiry
- UVa 424 - Integer Inquiry
- 424 - Integer Inquiry
- uva 424 - Integer Inquiry
- UVA - 424 - Integer Inquiry
- CentOS下安装Oracle 10g--上
- 两种常见排序算法
- CRM2011资源管理器
- 插入排序 (Insert Sort)
- 重新想象 Windows 8 Store Apps (34)
- 424 - Integer Inquiry
- 好的软件人员必看的60本书
- 通过Web用户控件实现注册(用委托方法)
- 2009年以来我买过的书(部分)
- uva 10635 - Prince and Princess
- javascript常见问题总结转载
- Android开发_ViewPager制作欢迎界面
- postgresql 分区表 创建函数
- C#接口实现多态