Problem D: Integer Inquiry
Problem D: Integer Inquiry
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 41 Solved: 12
[Submit][Status][Web Board]
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
my answer:
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace std;
int main()
{
char a[];
char b[];
memset(a,'',sizeof(a));
memset(b,'',sizeof(b)); while(cin>>b)
{
int sum[]={};
int t2=strlen(b),p=t2;
b[t2]='';
for(int i=;t2->=;i--,t2--){
b[i]=b[t2-];
b[t2-]='';
}
while(scanf("%s",a)&&strcmp(a,""))
{
int t1=strlen(a),q=t1;
a[t1]='';
for(int i=;t1->=;i--,t1--){
a[i]=a[t1-];
a[t1-]='';
}
for(int j=;j>=;j--)
b[j]=(b[j]-'')+(a[j]-'')+'';
for(int i=;i>=;i--)
sum[i]=b[i]-''; for(int j=;j>=;j--){
sum[j-]+=sum[j]/;
sum[j]=sum[j]%;
}
}
memset(a,'',sizeof(a));
memset(b,'',sizeof(b));
int start=;
for(int k=;k<=;k++)
if(sum[k]==)
start++;
else
break;
for(int k=start;k<=;k++)
cout<<sum[k];
cout<<endl;
}
return ;
}
Problem D: 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 ...
- 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 ...
- 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 ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDUOJ-----1074 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- 424 - Integer Inquiry
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. He extended his ...
随机推荐
- 【POJ】2492 A bug's life ——种类并查集
A Bug's Life Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 28211 Accepted: 9177 De ...
- [虚拟化/云][全栈demo] 为qemu增加一个PCI的watchdog外设(九)
目的 1. 使用verilog/vhdl设计一个PCI的watchdog设备. 2. 通过systemverilog 写testbench. 很久之前研究过AC97的verilog代码.但是很久没用v ...
- kvm在线磁盘扩展
1,查看指定kvm虚拟机的现有磁盘domblklist
- kvm中运行kvm
如何在 KVM 虚拟机上运行 KVM 上次讨论了如何在 VMware ESXi 虚拟机上运行 KVM 问题,前不久有读者想 “在 kvm 上面创建个虚拟机安装 rackspace 的 openstac ...
- ReactNative实现通知监听事件
事例1: 只在rn里面发送和接受消息. A界面: import {DeviceEventEmitter} from 'react-native'; //... componentDidMount(){ ...
- JS isArray记录
var isArray=Function.isArray||function(0){ return typeof o === "object" && Object. ...
- HDoj-1228-A + B
A + B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- 发现一个名为“Douyu”的国人项目
刚刚在javaeye看到一个名为Douyu的国人项目,认为搞下去未来可能非常有意思,放到blog上做个标记. ——————下面是转载的作者原文——————— 原文地址例如以下:http://zhh20 ...
- Activity中异步操作showDialog异常解决方法:判断Ay是否结束
Android – Displaying Dialogs From Background Threads 判断一下Activity是否在finishing就好了,否则万一Activity销毁了,这个D ...
- CentOS6.3下安装配置SVN(Subversion)
#检查是否安装了低版本的SVN [root@localhost ~]# rpm -qa subversion subversion--.el6.x86_64 #卸载旧版本SVN [root@local ...