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

Description

题目链接:http://poj.org/problem?id=1503

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

Source

题目描述:输入多个大数,求其和,输入以0结束。
代码:

 #include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
char f1[];
int sum[]={},i,j;
cin>>f1;
while(strcmp(f1,"")!=)
{
int t=strlen(f1),f[]={};
for(i=t-,j=;i>=;i--,j++)
f[j]=f1[i]-'';
int up=;
for(j=;j<=;j++)
{
int s=f[j]+sum[j]+up;
sum[j]=s%;
up=s/;
}
cin>>f1;
}
for(i=;i>=;i--)
if(sum[i]!=)
{
while(i>=)
{
cout<<sum[i];
i--;
}
break;
}
cout<<endl;
return ;
}

Integer Inquiry【大数的加法举例】的更多相关文章

  1. Integer Inquiry 大数加法

    Integer Inquiry 1 import java.util.*; 2 import java.math.*; 3 import java.io.*; 4 import java.text.* ...

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

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

  3. POJ 1503 Integer Inquiry(大数相加,java)

    题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...

  4. POJ 1503 Integer Inquiry(大数相加)

    一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...

  5. HDU 1047 Integer Inquiry 大数相加 string解法

    本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...

  6. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  7. Integer Inquiry(大数相加)

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

  8. HDU 1047 Integer Inquiry( 高精度加法水 )

    链接:传送门 思路:高精度水题 /************************************************************************* > File ...

  9. UVa 424 Integer Inquiry 【大数相加】

    解题思路:因为给定的数据是多组,所以我们只需要多次做加法就可以了,将上一次的和又作为下一次加法运算的一个加数. 反思:还是题意理解不够清楚,最开始以为只是算三个大数相加,后来才发现是多个,然后注意到当 ...

随机推荐

  1. 三. 动态添加option选项

  2. net-snmp-5.7.3配置编译安装

    net-snmp-5.7.3配置编译安装 [TOC] 先看一下系统环境 o@o-pc:~/work/_snmp/net-snmp-5.7.3$ uname -a Linux o-pc 3.16.0-3 ...

  3. poj3984

    定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, ...

  4. Centos安装firefox/chrome

    centos安装chrome:去官网下载chrome安装包(xxx.rpm),带软件安装工具的系统双击该xxx.rpm就能自动安装,或者sudo rpm -i xxx.rpm安装. centos卸载自 ...

  5. How can I determine the URL that a local Git repository was originally cloned from?

    git remote show origin from: http://stackoverflow.com/questions/4089430/how-can-i-determine-the-url- ...

  6. Buzz words

    给你一个字符串和字典,从头扫到位,如果到当前的字符的字符串存在于字典中,则显示 buzz. 例子: ILOVEPINEAPPLEJUICE 字典: [pine, apple, pineapple, j ...

  7. IPC---信号量

    一.什么是信号量 信号量的使用主要是用来保护共享资源,使得资源在一个时刻只有一个进程(线程) 所拥有. 信号量的值为正的时候,说明它空闲.所测试的线程可以锁定而使用它.若为0,说明 它被占用,测试的线 ...

  8. C#值数值类型转换

    1.十进制转16进制 string result=number.ToString("X2"); >>0A //X2表示大写2位 2.字符串转数值类型 "); ...

  9. PDF.js

    http://www.linuxidc.com/Linux/2015-06/118728.htm http://blog.csdn.net/xiangcns/article/details/42089 ...

  10. 使用php脚本查看已开启的扩展

    php安装时会将扩展包编译进去,对于一个正在运行中的数据库,查看php的扩展开启状况,第一种方式是通过配置文件查看,另外是通过phpinfo函数查看所有的配置,另外是使用php内置函数来查看,通过脚本 ...