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 ...
随机推荐
- iOS与H5交互(WKWbebView)
前言: 在iOS开发中,或多或少的会嵌入一些H5页面,有时候需要原生代码和H5页面进行交互.iOS8开始苹果推出性能更强大的WKWebView,所以一下方法是关于WKWebView与JS的交互. 创建 ...
- windows环境在本地配nginx
本地搭建了前端项目,但奈何有时候需要https访问的需求,所以做了一个尝试在本地(windows环境)下配置nginx,最终的效果就是 搭建的时候,遇到两个问题: 第一个是如果要在本地搭建https, ...
- Oracle debug
执行慢的使用使用debug环境变量,可以收集详细的日志 rootcrs.pl/roothas.pl执行慢 参考如下文档设置debug环境变量,重现问题并收集详细日志. How to turn on r ...
- 关于Linux与Windows的在服务器的一些区别
我们平时说学习运维要依托于Linux系统,因为在服务器领域Linux基本取得了市场,那么Linux在服务器领域与Windows相比有哪些优势呢?我们来看下:我们选择服务器主要是成本,安全稳定,这两大方 ...
- Cpython解释器GIL-多线程执行流程
- 接口自动化测试持续集成--Soapui接口功能测试数据传递
做接口测试经常会遇到如下两种情况需要处理数据传递 接口间的数据依赖,A接口请求的参数需要用到B接口的返回值 接口请求通常要用到鉴权的接口获取Token,Token通常会跟其他接口构成一对多的关系,这种 ...
- maven中target不能访问
原因是maven clean的时候已经把target文件夹删除 但是文件夹还存在页面中 所以我们看得到但是不能打开.正常操作是获得管理员权限删除后再重新clean,但是我电脑有360,直接360 ...
- 微博第三方js-sdk登录
https://open.weibo.com <meta property="wb:webmaster" content="your appkey" /& ...
- 通过本质看现象:关于Integer受内部初始化赋值范围限制而出现的有趣现象
左手代码,右手文章.——朱季谦 这是我的第一篇技术博客,作为一名技术小菜鸟,总体而言显得很拙见,但也算是成长路上的一个小脚印,希望能在以后的日子里,可以对JAVA技术有一个更加深入的思考与认识. 前几 ...
- 怎么把Thu Nov 22 2018 10:49:36 GMT+0800转换成正常日期
this.data //Thu Nov 22 2018 10:49:36 GMT+0800 this.date_of_birth = date.getFullYear() + '-' + (date. ...