hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11678 Accepted Submission(s): 2936
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 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.
This problem contains multiple test cases!
The
first line of a multiple input is an integer N, then a blank line
followed by N input blocks. Each input block is in the format indicated
in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
0
仅仅为了存一个高精度大数相加的模板
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <ctime>
using namespace std;
#define maxn 32768
void add(char a[],char b[],char back[])
{
int i,j,k,up,x,y,z,l;
char *c;
if (strlen(a)>strlen(b)) l=strlen(a)+; else l=strlen(b)+;
c=(char *) malloc(l*sizeof(char));
i=strlen(a)-;
j=strlen(b)-;
k=;up=;
while(i>=||j>=)
{
if(i<) x=''; else x=a[i];
if(j<) y=''; else y=b[j];
z=x-''+y-'';
if(up) z+=;
if(z>) {up=;z%=;} else up=;
c[k++]=z+'';
i--;j--;
}
if(up) c[k++]='';
i=;
c[k]='\0';
for(k-=;k>=;k--)
back[i++]=c[k];
back[i]='\0';
} int main()
{
int n;
scanf("%d",&n);
char a[maxn]="";
while(n--)
{
char b[maxn],c[maxn];
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
memset(a,'\0',sizeof(a));
a[]='';
while()
{
scanf("%s",b);
if(b[]=='')
break;
add(a,b,c);
strcpy(a,c);
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
}
if(n==)
printf("%s\n",a);
else
printf("%s\n\n",a); }
return ;
}
hdu acm-1047 Integer Inquiry(大数相加)的更多相关文章
- HDU 1047 Integer Inquiry 大数相加 string解法
本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...
- POJ 1503 Integer Inquiry(大数相加,java)
题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...
- POJ 1503 Integer Inquiry(大数相加)
一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...
- Integer Inquiry(大数相加)
Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...
- hdu 1047 Integer Inquiry
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1047 Integer Inquiry Description One of the first use ...
- hdoj 1047 Integer Inquiry
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Integer Inquiry 大数加法
Integer Inquiry 1 import java.util.*; 2 import java.math.*; 3 import java.io.*; 4 import java.text.* ...
- hdu 1047 Integer Inquiry(大数)
题意:整数大数加法 思路:大数模板 #include<iostream> #include<stdio.h> #include<stdlib.h> #include ...
- hdu 1047 Integer Inquiry(高精度数)
Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...
随机推荐
- expect使用demo
#!/usr/bin/expect set timeout set ip [lindex $argv ] spawn ssh root@$ip expect { "yes/no" ...
- miniui中常用的状态显示方式
1.查询sys_code表得到对应的状态 考生状态:<input class="mini-combobox" style="" textField=&qu ...
- http2协议翻译(转)
超文本传输协议版本 2 IETF HTTP2草案(draft-ietf-httpbis-http2-13) 摘要 本规范描述了一种优化的超文本传输协议(HTTP).HTTP/2通过引进报头字段压缩以及 ...
- Android部分调试开关
开启 GPU Render 的profiling bar: adb shell setprop debug.hwui.profile visual_bars #或visual_lines adb sh ...
- MAGENTA: Meta-Analysis Gene-set Enrichment of variaNT Associations
MAGENTA是一款计算工具,利用全基因组遗传数据,计算预先设定的涉及生物过程或者功能性基因集在遗传相关性的富集程度.开发的目的是分析基因型不是现成的数据集,比如大型的全基因组关联荟萃分析.在以下两种 ...
- 说说我的企业级应用上线历程(A little different!)
刚到公司时,我还是一个个人应用都没上线过的小白一枚,甚至都不知道.p12文件,不知道个人应用上线所使用的证书只能是自己机子创建的发布证书才可以打包上线,不知道企业级应用如何打包,不巧的是我还赶上了 i ...
- Time Series data 与 sequential data 的区别
It is important to note the distinction between time series and sequential data. In both cases, the ...
- WebService未能加载文件或程序集“ESRI.ArcGIS.XXX”或它的某一个依赖项
开发环境:Windows7旗舰版64bit.VisualStudio2008 With SP1.ArcEngine10.0.NetFrameWork4.0.IIS7和C#开发语言. 编写ArcEngi ...
- poj 2104 K-th Number (划分树入门 或者 主席树入门)
题意:给n个数,m次询问,每次询问L到R中第k小的数是哪个 算法1:划分树 #include<cstdio> #include<cstring> #include<alg ...
- Calculating Stereo Pairs
Calculating Stereo Pairs Written by Paul BourkeJuly 1999 Introduction The following discusses comput ...