poj 1503 Integer Inquiry (高精度运算)
题目链接: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 (高精度运算)的更多相关文章
- Poj 1503 Integer Inquiry
1.链接地址: http://poj.org/problem?id=1503 2.题目: Integer Inquiry Time Limit: 1000MS Memory Limit: 1000 ...
- POJ 1503 Integer Inquiry 大数 难度:0
题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...
- POJ 1503 Integer Inquiry(大数相加)
一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...
- 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 explo ...
- hdu 1047 Integer Inquiry(高精度数)
Problem Description Oneof the first users of BIT's new supercomputer was Chip Diller. He extended hi ...
- Integer Inquiry【大数的加法举例】
Integer Inquiry Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27730 Accepted: 10764 ...
- (大数 string) Integer Inquiry hdu1047
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu acm-1047 Integer Inquiry(大数相加)
Integer Inquiry Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
随机推荐
- UIView 中 frame, bounds, center 属性的关系
最近一直在学 iOS 开发,所以专门创建了这样一个类别,将自己学习中的一些问题整理,记录下来.由于自己是初学者,所以所写的文章非常基础,写这个类别一是为了给自己留下存 档,二是为了给和我有同样问题的初 ...
- android 围绕中心旋转动画
本文主要介绍Android中如何使用rotate实现图片不停旋转的效果.Android 平台提供了两类动画,一类是 Tween 动画,即通过对场景里的对象不断做图像变换(平移.缩放.旋转)产生动画效果 ...
- PID教程
PID教程 介绍 本教程将向您展示了比例每一个比例项 (P)的特点,积分项(I)和微分项 (D) 控制,以及怎样使用它们来获得所需的响应.在本教程中,我们会考虑下面单位反馈系统: Plant[被控对象 ...
- JavaSE复习日记 : 算是个小前言吧
/* * Java也学了好久了,抽个时间整理了一下课堂笔记,也有些是我刚开始学会犯的一些错误.在这里浅谈一下JavaSE的基础内容,对我来说也是一种不错的复习方式. * * 那好,对于初学者来说,学习 ...
- Mac搭建Java开发环境
参考博文: http://shupeng.org/2012/10/14/config-java-env-on-mac/ http://hdu104.com/23 注意事项: (Mac OS X - M ...
- jmeter cookie管理器 使用方法---新手学习记录1
首先得抓包: 我已post方法为例: POST /api/datasources/lemontest/jaql HTTP/1.1 Host: 192.168.1.107:8081 Content-Le ...
- 精通UNIX下C语言编程与项目实践
cc -I //include 目录 -L //静态库目录?动态也可以 -l //小写L,接静态库名称?动态也可以 -DXXX='"XXFF"' //-D直接定义宏 -c 只编 ...
- 自定义Chrome 背景色 (FF需要User Styles插件)
Chrome有个自定义背景色的文件 Custom.css 默认里面什么字都没写 html, body {background-color: #e0dcc0!important;} 这个颜色 ...
- CodeIgniter结合Bootstrap
CodeIgniter-Bootstrap结合了 cI和bootstrap的长处,一个专注于服务器端,一个专注于ui,这个把2个结合起来了.框架地址: http://www.andyhawthorne ...
- Ubuntu离线安装软件包
一.应用场景 a.当我们需要在多台电脑安装同一个软件,并且这个软件很大,下载需要很长时间时 b.需要安装软件的ubuntu不能上网 二.离线安装包的制作 2.1.通过如下指令下载XXXX软件所需要的d ...