Integer Inquiry

Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u

Submit Status

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.) 

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

123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0

Sample Output

370370367037037036703703703670

 #include<stdio.h>
#include<string.h> char a[][] ;
char sum[] ; void add (char temp[] ) { int rem = ;
int k ;
int i ;
for (i = ; temp[i] != '\0' ; i++ ) {
if ( ( k = temp[i] - '' + sum[i] - '' + rem ) >= ) {
rem = ;
sum[i] = '' + k - ;
}
else {
rem = ;
sum[i] = '' + k ;
}
}
if ( rem == )
sum[i] = '' ;
for ( k = strlen (sum) - ; sum[k] == && k >= ; k-- ) ;
if ( k == -)
sum[k + ] = '\0' ;
else
sum[k + ] = '\0' ; } int main () {
// freopen ("a.txt" ,"r" , stdin ) ;
int n ;
int ls , li ;
int j ;
while ( gets(a[]) != NULL ) {
n = ;
while ( strcmp(a[n - ] , "") != ) {
gets (a[n++]) ;
}
strcpy (sum , a[] ) ;
strrev (sum) ; for (int i = ; i < n; i++ ) {
li = strlen (a[i]) ;
ls = strlen (sum) ;
strrev (a[i]) ;
if ( li > ls ) {
for (j = ls ; j < li ; j++ ) {
sum[j] = '' ;
}
sum[j] = '\0' ;
}
else {
for (j = li ; j < ls ; j++ ) {
a[i][j] = '' ;
}
a[i][j] = '\0' ;
}
add ( a[i] ) ;
}
strrev (sum) ;
puts (sum) ;
}
return ;
}

试试 1 + 9 或 直接输入 0

Integer Inquiry的更多相关文章

  1. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. Integer Inquiry【大数的加法举例】

    Integer Inquiry Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27730   Accepted: 10764 ...

  3. 424 - Integer Inquiry

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...

  4. hdu1047 Integer Inquiry

    /* Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...

  5. hdu 1047 Integer Inquiry

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...

  6. UVa 424 Integer Inquiry

    之前杭电上也做过a + b的高精度的题,不过这道题的区别是有多组数据. 之前做的时候开了3个字符数组a,b,c,在计算的时候还要比较a,b长度,短的那个还要加'0',还设置了一个add来存放进位. 现 ...

  7. Poj 1503 Integer Inquiry

    1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS   Memory Limit: 1000 ...

  8. hdoj 1047 Integer Inquiry

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. Problem D: Integer Inquiry

    Problem D: Integer InquiryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 41 Solved: 12[Submit][Status ...

随机推荐

  1. 你所不知道的Python奇技淫巧

    有时候你会看到很Cool的Python代码,你惊讶于它的简洁,它的优雅,你不由自主地赞叹:竟然还能这样写.其实,这些优雅的代码都要归功于Python的特性,只要你能掌握这些Pythonic的技巧,你一 ...

  2. 小白学习mysql之优化基础(EXPLAIN的连接类型)

    ## 导语很多情况下,有很多人用各种select语句查询到了他们想要的数据后,往往便以为工作圆满结束了.这些事情往往发生在一些学生亦或刚入职场但之前又没有很好数据库基础的小白身上,但所谓闻道有先后,只 ...

  3. [C/C++基础] C语言常用函数memset的使用方法

    函数声明:void *memset(void *s, int ch, size_t n); 用途:为一段内存的每一个字节都赋予ch所代表的值,该值采用ASCII编码. 所属函数库:<memory ...

  4. 【niubi-job——一个分布式的任务调度框架】----FAQ文档

    引言 本文为niubi-job的FAQ文档,该文档会无限更新.如果您在这里没有找到您想要的答案,请把问题提交到这里. FAQ 1.为什么我的所有任务总是运行在同一个节点上,而没有平均分配到所有节点上? ...

  5. ModelProxy 前端接口配置建模框架

    ModelProxy    轻量级的接口配置建模框架(1) 先看一下这个博客说明为什么需要用ModelProxy的前端轻量级的框架吧:  http://developer.51cto.com/art/ ...

  6. [POJ3177]Redundant Paths(双联通)

    在看了春晚小彩旗的E技能(旋转)后就一直在lol……额抽点时间撸一题吧…… Redundant Paths Time Limit: 1000MS   Memory Limit: 65536K Tota ...

  7. Java-小数点控制

    package 运算及类型转换类; import java.text.DecimalFormat; public class 控制小数点类 { public static double decimal ...

  8. 用php生成数据字典

    <?php header("Content-type: text/html; charset=utf-8"); $dbserver = "localhost&quo ...

  9. 点击Cell中的按钮时,如何取所在的Cell

    4.点击Cell中的按钮时,如何取所在的Cell:-(void)OnTouchBtnInCell:(UIButton *)Btu{CGPoint point = btn.center;point = ...

  10. 【BZOJ-3172】单词 AC自动机

    3172: [Tjoi2013]单词 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 2567  Solved: 1200[Submit][Status ...