题目链接: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. angularjs-ngTable select filter

    jsp <td title="'Status'" filter="{status: 'select'}" filter-data="fn.sta ...

  2. C#中的Dictionary字典类介绍

      Dictionary字典类介绍 必须包含名空间System.Collection.Generic    Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值)    键必须是 ...

  3. Gprinter Android SDK V2.1.4 使用说明

    佳博打印机Android的SDK开发包,已更新到Gprinter Android SDK V2.1.4. IOS的SDK开发包更新为GprinterSDKandDemoforIOS_v1.0.8. 根 ...

  4. SQL觸發器聯級刪除

    Create TRIGGER [dbo].[trigInstructionsDelete] ON dbo.Instructions instead OF DELETE AS BEGIN DECLARE ...

  5. C# 线程数

    理论上,一个进程可用虚拟空间是2G,默认情况下,线程的栈的大小是1MB,所以理论上最多只能创建2048个线程,但是一般不会到这么大,因为主线程要占内存,可能还要多点.如果要创建多于2048的话,必须修 ...

  6. JQuery 绑定回车事件 兼容ie8,ie9

    $("#form-search").find('#search-query').bind('keypress', function(e) { var keycode; if(win ...

  7. Ubuntu 创建快捷方式的方法

    ln -s  /要创建快捷方式的地方/ /创建在哪里/

  8. ObjectiveC1基础代码——类和对象

    // //  main.m //  ObjectiveC1 // //  Created by scjy on 15/10/30. //  Copyright © 2015年 lizhipeng. A ...

  9. ACM组队安排

    Problem Description   ACM亚洲区比赛结束,意味着开始备战明年的浙江省大学生程序设计竞赛了!  杭州电子科技大学ACM集训队也准备开始组队.  教练想把所有的n个队员组成若干支队 ...

  10. outline属性

    outline(轮廓)用于设置元素周围的一条线,用于元素边框的外围,可起到突出元素的作用. outline属性所有浏览器都支持,如果规定了 !DOCTYPE,则 IE8 支持 outline 属性. ...