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. ASP.NET MVC 5 入门教程 (2) 控制器Controller

    文章来源: Slark.NET-博客园 http://www.cnblogs.com/slark/p/mvc-5-get-started-controller.html 上一节:ASP.NET MVC ...

  2. WIN8 浏览器排版不兼容问题

    经常访问网站失败 访问部分网站只显示白底蓝字没有排版也没有图片 尝试了网上的各种方法,也是用了360和百度安全管家的网页修复 重置了IE设置 都不行!!! 最后有效的方法是 更换DNS 208.67. ...

  3. OOP多态和继承要点

         早期绑定和多态 C#函数重载的签名规则是用参数的类型和数量判断,而不是函数的名字. 函数返回值不作为重载签名. 修饰符不作为签名的一部分,如static 同函数中,多个参数名称要唯一 ref ...

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

    函数声明:extern unsigned int strlen(char *s); 所属函数库:<string.h> 功能:返回s所指的字符串的长度,其中字符串必须以’\0’结尾 参数:s ...

  5. DateTime.Parse

    上月第一天:DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01")) 上周星期天:DateTime.Par ...

  6. [CH#58解题报告]

    题目:http://206.contesthunter.org/contest/CH%20Round%20%2358%20-%20OrzCC%E6%9D%AFnoip%E6%A8%A1%E6%8B%9 ...

  7. mysql配置详解

    mysql有以下几种日志:  错误日志:    log-err  查询日志:    log  慢查询日志:  log-slow-queries  更新日志:    log-update  二进制日志: ...

  8. 每天一个linux命令(12):head 命令

    head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾. 1.命令格式: hea ...

  9. github的初次体验及管理代码的心得

    周六早上的课上,助教给我们演示了一遍如何上传和下载代码库,新建代码库等等,但是是在linux上的,而我的笔记本的操作系统是win7的.而在教室中的尝试因为网络原因,虽然可以上github的网站,但是下 ...

  10. 拦路虎:jQuery

    1.   color设置无效的问题! $("#subscribe").hover(function(){ var $this = $("#subscribe .subsc ...