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 ...
随机推荐
- WPF简单导航框架(Window与Page互相调用)
相当多的WPF程序都有着丰富的页面和功能,如何使程序在不同页面间转换并降低资源占用,选择适合自己的导航框架就很重要了.最近花了一点时间做了一个简单的导航框架,并在这个过程中对Window.Page.U ...
- Devexpress WidgetView 使用总结
效果图: 1.添加DocumentManager控件 2.Convert to WidgetView 3.添加Document,设定ControlTypeName属性,第5步用到 4.添加StackG ...
- POJ 1015 Jury Compromise 2个月后重做,其实这是背包题目
http://poj.org/problem?id=1015 题目大意:在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑选n个人作为陪审团的候选人,然后再从 ...
- Windows 2012 R2图标以及字体颜色发生变化更改成默认设置
1. 在桌面按"Win+R",然后输出regedit.2. 定位到HKEY_CURRENT_USER\Control panel\Colors3. 对照下面提供给您的初始化颜色的注 ...
- Eclipse里面的一些常规设置
一.Eclipse里面的默认编码是GBK,但是Android开发的编码都是UTF-8,所以一定要修改自己的工程的编码,不要坑队友哦~ (1)选中当前的工程,点击右键,如图选择(这只是改变当前工程的编码 ...
- JavaBean的toString方法工具类
import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.r ...
- spark2.0配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- Oracle 11g服务详细介绍及哪些服务是必须开启的?
安装oracle 11g R2中的方法成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为: 1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝 ...
- 《Reactive_MircService_Architecture》 脑图
Reactive_MircService_Architecture Lightbend CTO的50页的小册子,对响应式系统以及微服务架构介绍非常全面,整理了一个脑图来先.
- solr安装笔记与定时器任务
一:solr启动 目前solr最高版本为5.5.0版本,很多solr安装都是说将server文件copy到tomcat中,但是solr版本自带有jetty的启动方式 首先下载solr-5.5.0版本, ...