题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4608

 #include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#define maxn 105000
using namespace std; int len;
char a[maxn],b[maxn]; int getsum(){
int ans = ; //printf("%d\n",len);
for(int i=;i<len;i++){
ans += a[i] - '';
}// printf("ans %d\n",ans);
return ans;
}
void add(int num){
int incnt = ;
int temp = a[] - '' + num; //printf("temp %d\n",temp); if(temp > ){
incnt = ;
a[] = temp - + ''; //printf("*** %c %d\n",a[0],temp);
}
else a[] = temp + '';
int cnt = ;
while(incnt && cnt < len){
temp = a[cnt] - '' + incnt;
if(temp>){
incnt = ;
a[cnt] = temp - + '';
}
else {incnt = ; a[cnt] = temp + '';}
cnt++;
}
if(incnt && cnt == len){
a[cnt] = '';
len ++;
}
} int main()
{
//if(freopen("input.txt","r",stdin)== NULL) {printf("Error\n"); exit(0);} int T;
cin>>T;
while(T--){ int numzero = ;
scanf("%s",b); while(b[numzero] == ''){
numzero++;
} int cnt = numzero;
len = ;
for(int i=;b[cnt]!='\0';i++) {a[i] = b[cnt++]; len++; } for(int i=;i<len/;i++){
int temp = a[i];
a[i] = a[len--i];
a[len--i] = temp;
}
int sum = getsum()%; //printf("%d %d\n",len,sum);
if(sum == ) sum = ;
int time = ;
while(sum != && time < ){
add(); //printf("%d %d\n",len,sum);
sum = getsum()%;
time++;
}
while(numzero--) printf("");
for(int i=len-;i>=;i--) printf("%c",a[i]);
printf("\n");
}
}

hdu 4608 I-number 大整数的更多相关文章

  1. HDU 1002 A + B Problem II(大整数相加)

    A + B Problem II Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

  2. 1024 Palindromic Number int_string转换 大整数相加

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  3. PAT A1024 Palindromic Number (25 分)——回文,大整数

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  4. hdu 1316(大整数)

    How Many Fibs? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  5. HDU 3533 Escape(大逃亡)

    HDU 3533 Escape(大逃亡) /K (Java/Others)   Problem Description - 题目描述 The students of the HEU are maneu ...

  6. [转载]JavaScript 中小数和大整数的精度丢失

    标题: JavaScript 中小数和大整数的精度丢失作者: Demon链接: http://demon.tw/copy-paste/javascript-precision.html版权: 本博客的 ...

  7. hdu 2665 Kth number

    划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...

  8. HDOJ-1002 A + B Problem II (非负大整数相加)

    http://acm.hdu.edu.cn/showproblem.php?pid=1002 输入的数都是正整数,比较好处理,注意进位. //非负大整数加法 # include <stdio.h ...

  9. 自己动手写Java大整数《3》除法和十进制转换

    之前已经完毕了大整数的表示.绝对值的比較大小.取负值.加减法运算以及乘法运算. 详细见前两篇博客(自己动手写Java * ). 这里加入除法运算. 另外看到作者Pauls Gedanken在blog( ...

  10. Java 实现大整数加减乘除

    自己用Java实现的大整数加减乘除运算.还有可以改进的地方,有兴趣的童鞋可以加以改进.仅供参考,请勿转载! package barrytest; import java.util.ArrayList; ...

随机推荐

  1. spring集成 log4j + slf4j

    以maven web项目为例, 首先.在pom文件引入相关依赖,如下(spring官网文档有介绍): <dependencies> <!-- spring 相关 --> < ...

  2. power desinger 学习笔记<一>

    如果一张表有 很多字段(多于30个),那么一个一个复制粘贴,耗时耗力.可以偷懒,事先编辑好 sql脚本,然后把sql脚本导入 power designer,是不是很方便?  看下面的 1. 打开Pow ...

  3. oracle 报错 :ORA-04052、 ORA-00604、 ORA-03106、 ORA-02063

    最近发现一个很奇怪的问题: 创建了一个DB_LINK连接另一个Oracle数据库. select * from tablename@dblinkname; 单句执行没问题,但是把这句SQL写到存储过程 ...

  4. Unity Manual 用户手册

    unity3d 文档的中文网址:   http://game.ceeger.com/Manual/

  5. 子树大小平衡树(Size Balanced Tree,SBT)操作模板及杂谈

    基础知识(包括但不限于:二叉查找树是啥,SBT又是啥反正又不能吃,平衡树怎么旋转,等等)在这里就不(lan)予(de)赘(duo)述(xie)了. 先贴代码(数组模拟): int seed; int ...

  6. 利用WebRequest类上传文件

    说明:1.WebRequest类是一个抽象类,所以上传类实际使用的是其子类 2.打开Fiddler软件,监视正常网页的文件上传,可以看到http协议的请求和响应信息,简略说明 (第一行:请求说明 PO ...

  7. JavaScript中document.cookie

    “某些 Web 站点在您的硬盘上用很小的文本文件存储了一些信息,这些文件就称为 Cookie.”—— MSIE 帮助.一般来说,Cookies 是 CGI 或类似,比 HTML 高级的文件.程序等创建 ...

  8. python json string和dict的转化

    __author__ = 'SRC_TJ_XiaoqingZhang' import json data1 = {'b': 789, 'c': 456, 'a': 123} encode_json = ...

  9. Python Tutorial 学习(八)--Errors and Exceptions

    Python Tutorial 学习(八)--Errors and Exceptions恢复 Errors and Exceptions 错误与异常 此前,我们还没有开始着眼于错误信息.不过如果你是一 ...

  10. [r]Setting up Django and your web server with uWSGI and nginx

    Setting up Django and your web server with uWSGI and nginx This tutorial is aimed at the Django user ...