Integer Inquiry
Description
``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 final input line will contain a single zero on a line by itself.
Output
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的更多相关文章
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- 424 - Integer Inquiry
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...
- hdu1047 Integer Inquiry
/* Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- UVa 424 Integer Inquiry
之前杭电上也做过a + b的高精度的题,不过这道题的区别是有多组数据. 之前做的时候开了3个字符数组a,b,c,在计算的时候还要比较a,b长度,短的那个还要加'0',还设置了一个add来存放进位. 现 ...
- Poj 1503 Integer Inquiry
1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS Memory Limit: 1000 ...
- hdoj 1047 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Problem D: Integer Inquiry
Problem D: Integer InquiryTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 41 Solved: 12[Submit][Status ...
随机推荐
- 数据挖掘系列(2)--关联规则FpGrowth算法
上一篇介绍了关联规则挖掘的一些基本概念和经典的Apriori算法,Aprori算法利用频繁集的两个特性,过滤了很多无关的集合,效率提高不少,但是我们发现Apriori算法是一个候选消除算法,每一次消除 ...
- IT男的”幸福”生活"续1
IT男的”幸福”生活"续1 我和LL开始下步追妹计划...... 知彼知已,方能把握机会.没想到孙子兵法太给力了,据LL了解,MM(她)是湖北人,找对象一般不会考虑外省的.高度165左右,相 ...
- Visual Studio命令窗口
命令”窗口用于直接在 Visual Studio 集成开发环境 (IDE) 中执行命令或别名.可以执行菜单命令和不在任何菜单上显示的命令.若要显示“命令”窗口,请从“视图”菜单中选择“其他窗口”,再选 ...
- 机器学习中的矩阵方法(附录A): 病态矩阵与条件数
1. 病态系统 现在有线性系统: Ax = b, 解方程 很容易得到解为: x1 = -100, x2 = -200. 如果在样本采集时存在一个微小的误差,比如,将 A 矩阵的系数 400 改变成 4 ...
- 自己在OC考试中的试题
Objective-C考试 [关闭] ※ 选择题(共40题,每题2分) 1. 以下说法正确的是________. 答案:(C) A.alloc,retain,release,dealloc都会使对 ...
- Ibatis学习总结5--动态 Mapped Statement
直接使用 JDBC 一个非常普遍的问题是动态 SQL.使用参数值.参数本身和数据列都 是动态的 SQL,通常非常困难.典型的解决方法是,使用一系列 if-else 条件语句和一连串 讨厌的字符串连接. ...
- JavaEE EL的一些用法
EL 可以在指示元素中设置EL是否使用 isELIgnored="true" true是不使用 也可以在web.xml中使用 <jsp-config> <jsp- ...
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
java.lang.IllegalStateException: getWriter() has already been called for this response问题解决 java.lang ...
- opencv笔记3:trackbar简单使用
time:2015年 10月 03日 星期六 13:54:17 CST # opencv笔记3:trackbar简单使用 当需要测试某变量的一系列取值取值会产生什么结果时,适合用trackbar.看起 ...
- Linux登录验证机制、SSH Bruteforce Login学习
相关学习资料 http://files.cnblogs.com/LittleHann/linux%E4%B8%AD%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95%E8%AE% ...