题目链接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. 7kb的javascript日期操作类库(XDate)

    A Modern JavaScript Date Library XDate is a thin wrapper around JavaScript's native Date object that ...

  2. ASPxGridView-如何在客户端缓存数据

    有时候我们可以直接从后台生成一些值缓存到客户端,在用到的时候无需在进行callback进行取值,减少和服务器的交互.下面的例子缓存列"title_id"和"title&q ...

  3. zoj 1962 How Many Fibs?(字符串化为数字处理)

    事实证明还是,题目拿到手之后,还是还是好好动手划一下比较好,不然直接想打哪!打到哪!很容易乱掉的.将数字倒着弄成字符串比较好处理. #include<stdio.h> #include&l ...

  4. C语言:类似linux内核的分等级DEBUG宏(打印宏)

    总结几种log打印printf函数的宏定义 http://blog.chinaunix.net/uid-20564848-id-73402.html #include <stdio.h> ...

  5. 在mac系统安装Apache Tomcat的详细步骤(转载自himi的博客,修改了错误添加了图片)

    链接地址:http://blog.csdn.net/liuyuyefz/article/details/8072485 1. 2. 3. 4. 5. 对于Apache Tomcat 估计很多童鞋都会, ...

  6. c++ primer plus 习题答案(3)

    p296.3 #include<iostream> #include<cstdlib> #include<string> #include<cstring&g ...

  7. C++对象模型6--对象模型对数据访问的影响

    如何访问成员? 前面介绍了C++对象模型,下面介绍C++对象模型的对访问成员的影响.其实清楚了C++对象模型,就清楚了成员访问机制.下面分别针对数据成员和函数成员是如何访问到的,给出一个大致介绍. 对 ...

  8. 打印 PHP $_SERVER 常量

    foreach( $_SERVER as $var => $value){ echo $var.' '.$value.'<br>'; };

  9. Python开发环境Spyder安装方法

    Spyder(Scientific PYthon Development EnviRonment)是一个强大的交互式 Python 语言开发环境,提供高级的代码编辑.交互测试.调试等特性,支持包括 W ...

  10. Android开发之TextView高级应用

    Android开发之TextView高级应用 我们平时使用TextView往往让它作为一个显示文字的容器,但TextView的功能并不局限于此.以下就和大家分享一下TextView的一些使用技巧. A ...