1047 Integer Inquiry
String 大数加法模板
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std; //高精度加法
//只能是两个正数相加
string add(string str1,string str2)//高精度加法
{
string str; int len1=str1.length();
int len2=str2.length();
//前面补0,弄成长度相同
if(len1<len2)
{
for(int i=;i<=len2-len1;i++)
str1=""+str1;
}
else
{
for(int i=;i<=len1-len2;i++)
str2=""+str2;
}
len1=str1.length();
int cf=;
int temp;
for(int i=len1-;i>=;i--)
{
temp=str1[i]-''+str2[i]-''+cf;
cf=temp/;
temp%=;
str=char(temp+'')+str;
}
if(cf!=) str=char(cf+'')+str;
return str;
} int main()
{
int T;
scanf("%d",&T);
while(T--)
{
string sum="";
string str1;
while(cin>>str1)
{
if(str1=="")break;
sum=add(sum,str1);
}
cout<<sum<<endl;
if(T>)cout<<endl;
}
return ; }
1047 Integer Inquiry的更多相关文章
- 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 ...
- hdu 1047 Integer Inquiry(高精度数)
Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...
- hdu 1047 Integer Inquiry(大数)
题意:整数大数加法 思路:大数模板 #include<iostream> #include<stdio.h> #include<stdlib.h> #include ...
- HDU 1047 Integer Inquiry 大数相加 string解法
本题就是大数相加,题目都不用看了. 只是注意的就是HDU的肯爹输出,好几次presentation error了. 还有个特殊情况,就是会有空数据的输入case. #include <stdio ...
- HDU 1047 Integer Inquiry( 高精度加法水 )
链接:传送门 思路:高精度水题 /************************************************************************* > File ...
- 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 ...
随机推荐
- theano使用GPU踩坑
1.安装pygpu的部分 #使用豆瓣源or不使用,均安装失败 pip install pygpu -i http://pypi.douban.com/simple/ --trusted-host py ...
- oo第二次博客总结
不知道怎么说好呢,自己对自己也很没有信心的,希望自己能做出些许改变
- MyEclipse破解步骤
1.下载安装(注:安装后不要打开myeclipse,以下步骤完成方可打开) 2.解压破解文件 3.打开文件夹patch 3.全部复制 4.找到myeclipse的安装目录,打开plugins文件夹 5 ...
- 安装Oracle Grid的过程中用到的几个小技巧
1.利用文件来模拟块设备 在grid的安装教程中有一步是 provision the disk devices for use with ASM Filter Driver.但是如果我们没有多个磁盘怎 ...
- C# 实现http不同方法的请求
p{ text-align:center; } blockquote > p > span{ text-align:center; font-size: 18px; color: #ff0 ...
- [ISSUE] [Centos] Centos Start Nginx Show: Failed to start nginx.service:unit not found
CMD Line:systemctl start nginx.serviceFailed to start nginx.service: Unit not found. Solution: 1.vim ...
- GO : 斐波纳契数列
package main import "fmt" // fibonacci is a function that returns // a function that retur ...
- HTML5培训入门基础知识了解CSS3 3D属性
CSS3 3D 什么是3d的场景呢? 2d场景,在屏幕上水平和垂直的交叉线x轴和y轴 3d场景,在垂直于屏幕的方法,相对于3d多出个z轴 Z轴:靠近屏幕的方向是正向,远离屏幕的方向是反向 CSS3中的 ...
- python-列表与元组
列表(List) 特性: 列表也是一种Sequence 类型 下标 能切片 可以存储任何类型的数据,每个元素是任意类型,可以存放任 ...
- Linux串口通信之termios结构体说明
termios结构体中,该结构体一般包括如下的成员:tcflag_t c_iflag; tcflag_t c_oflag; tcflag_t c_cflag; tcfla ...