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 ...
随机推荐
- html5 canvas 粒子特效
不知不觉就已经好久没写过博客了,自从七月正式毕业后,离开了实习了将近九个月的老东家,进了鼠厂后,做的事都是比较传统的前端活,之前在tpy的时候只管做移动h5的特效以及小游戏,再加上实习所以时间比较充裕 ...
- Mustache.js前端模板引擎源码解读
mustache是一个很轻的前端模板引擎,因为之前接手的项目用了这个模板引擎,自己就也继续用了一会觉得还不错,最近项目相对没那么忙,于是就抽了点时间看了一下这个的源码.源码很少,也就只有六百多行,所以 ...
- js判断页面出现滚动条
当可视区域小于页面的实际高度时,判定为出现滚动条 当我们在获取页面的offsetHeight高度时是包括了浏览器的边框的,浏览器的边框是2个像素, if (document.documentEleme ...
- [BZOJ 2656][ZJOI2012]数列(递归+高精度)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=2656 分析: 很容易想到递归分治,但遇到奇数时候f[i]=f[i/2]+f[i/2+1 ...
- [bzoj 1004][HNOI 2008]Cards(Burnside引理+DP)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1004 分析: 1.确定方向:肯定是组合数学问题,不是Polya就是Burnside,然后题目上 ...
- Linq之隐式类型、自动属性、初始化器、匿名类
目录 写在前面 系列文章 隐式类型 自动属性 初始化器 匿名类 总结 写在前面 上篇文章是本系列的小插曲,也是在项目中遇到,觉得有必要总结一下,就顺手写在了博客中,也希望能帮到一些朋友.本文将继续介绍 ...
- JS表单学习笔记(思维导图)
导图
- Java基础-父类-子类执行顺序
代码解析 子类 package com; /** * 子类 * @author huage * */ public class Test extends Test1{ public static vo ...
- Oracle之自定义函数
数据库中函数包含四个部分:声明.返回值.函数体和异常处理. --没有参数的函数 create or replace function get_user return varchar2 is v_use ...
- 点击div区域以外部分,div区域隐藏
核心思想: 监听body的click事件,事件触发的时候判断是否发生在弹出的div上,如果不在,关闭弹层 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTM ...