题目链接http://poj.org/problem?id=1503

思路分析: 基本的高精度问题,使用字符数组存储然后处理即可。

代码如下

#include <iostream>
#include <string>
using namespace std; const int M = + ;
char input[M];
int A[M], sum[M]; void Reverse(int A[], const char str[])
{
int len = strlen(str);
int index = ; for (int i = len - ; i >= ; --i)
A[index++] = str[i] - '';
} int main()
{
int sumLen = ; memset(sum, , sizeof(sum));
while (scanf("%s", input) != EOF)
{
int digitSum; if (strcmp(input, "") == )
break;
memset(A, , sizeof(A));
Reverse(A, input);
for (int i = ; i < M; ++i)
{
digitSum = sum[i] + A[i];
sum[i] = digitSum % ;
sum[i+] += digitSum/;
}
}
for (int i = M-; sum[i] == ; --i)
sumLen = i;
for(int i = sumLen-; i >= ; --i)
printf("%d", sum[i]);
printf("\n"); return ;
}

poj 1503 Integer Inquiry (高精度运算)的更多相关文章

  1. Poj 1503 Integer Inquiry

    1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS   Memory Limit: 1000 ...

  2. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  3. POJ 1503 Integer Inquiry(大数相加)

    一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...

  4. POJ 1503 Integer Inquiry(大数相加,java)

    题目 我要开始练习一些java的简单编程了^v^ import java.io.*; import java.util.*; import java.math.*; public class Main ...

  5. POJ 1503 Integer Inquiry 简单大数相加

    Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...

  6. hdu 1047 Integer Inquiry(高精度数)

    Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...

  7. Integer Inquiry【大数的加法举例】

    Integer Inquiry Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27730   Accepted: 10764 ...

  8. (大数 string) Integer Inquiry hdu1047

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. hdu acm-1047 Integer Inquiry(大数相加)

    Integer Inquiry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

随机推荐

  1. 练习笔记:net,JqueryUI实现自动补全功能

    1.首先建立个空的Web项目 2.将下载好的JqueryUI文件保存到JS文件加下 3.引入JS文件 <link href="JS/css/ui-lightness/jquery-ui ...

  2. sql Servers数据库基础

    1. 数据库约束包含:     ·非空约束     ·主键约束(PK) primary key constraint 唯一且不为空     ·唯一约束(UQ) unique constraint 唯一 ...

  3. java 錯誤集錦.

    (1)加载驱动成功com.microsoft.sqlserver.jdbc.SQLServerException: 不支持此服务器版本.目标服务器必须是 SQL Server 2000 或更高版本.链 ...

  4. objective-C学习笔记(四)函数成员:方法(函数)

    函数分为:  全局函数(C语言函数) 成员函数(OBJC方法):实例方法 “-” 和类方法“+”的区别 //这里要区别静态变量(类变量).全局函数.常量的区别 OBJC里面,所有方法默认为公有方法.没 ...

  5. IOS使用pch预编译文件

    首先新建一个pch文件,然后要修改这个项目的Build Setting中的Prefix Header 修改为 $(SRCROOT)/项目名称/预编译文件名: 一般pch文件的用处: 1.导入框架,如: ...

  6. iOS 纯代码适配iPhone6,6+

    链接地址:http://blog.csdn.net/codywangziham01/article/details/37658399 转自:http://www.maxiaoguo.com/cloth ...

  7. 第一节 生命周期和Zend引擎

    一切的开始: SAPI接口 SAPI(Server Application Programming Interface)指的是PHP具体应用的编程接口, 就像PC一样,无论安装哪些操作系统,只要满足了 ...

  8. 数据库比对脚本(PHP版)

    $config = [ 'hotfix' => [ 'host'=>'', 'port'=>'', 'account'=>'', 'password'=>'', 'dat ...

  9. 解决python2.7.9以下版本requests访问https的问题

    在python2.7.9以下版本requests访问https连接后,总会报一些关于SSL warning. 解决法子可以参考:https://urllib3.readthedocs.io/en/la ...

  10. selenium 学习笔记 ---新手学习记录(7) 问题总结(java)

    1.想要获取固定ul下所有li的个数  如下图: //获取ul下li的个数 List<WebElement> elements = driver.findElement(By.id(&qu ...