hdu 4608 I-number 大整数
题目链接: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 大整数的更多相关文章
- HDU 1002 A + B Problem II(大整数相加)
A + B Problem II Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u De ...
- 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 ...
- 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 ...
- hdu 1316(大整数)
How Many Fibs? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 3533 Escape(大逃亡)
HDU 3533 Escape(大逃亡) /K (Java/Others) Problem Description - 题目描述 The students of the HEU are maneu ...
- [转载]JavaScript 中小数和大整数的精度丢失
标题: JavaScript 中小数和大整数的精度丢失作者: Demon链接: http://demon.tw/copy-paste/javascript-precision.html版权: 本博客的 ...
- hdu 2665 Kth number
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...
- HDOJ-1002 A + B Problem II (非负大整数相加)
http://acm.hdu.edu.cn/showproblem.php?pid=1002 输入的数都是正整数,比较好处理,注意进位. //非负大整数加法 # include <stdio.h ...
- 自己动手写Java大整数《3》除法和十进制转换
之前已经完毕了大整数的表示.绝对值的比較大小.取负值.加减法运算以及乘法运算. 详细见前两篇博客(自己动手写Java * ). 这里加入除法运算. 另外看到作者Pauls Gedanken在blog( ...
- Java 实现大整数加减乘除
自己用Java实现的大整数加减乘除运算.还有可以改进的地方,有兴趣的童鞋可以加以改进.仅供参考,请勿转载! package barrytest; import java.util.ArrayList; ...
随机推荐
- 【POJ3468】【zkw线段树】A Simple Problem with Integers
Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. On ...
- 第四篇、Tomcat 集群
1. 前言 该篇中测试的机器发生了变更,在第一篇中设置的Apache DocumentRoot "d:/deployment"修改为了DocumentRoot d:/clust ...
- springMVC整合memcached,以注解形式使用
睡不着,深夜写点博客.闲下来有一个月了,心里多少有点…… 在北京找工作一再受阻,这个时间点也不好找 再接再厉 之前没有用过memcached,没有什么实战经验,看了一些关于memcached的博客,写 ...
- js实现placeholder效果
<form name="testForm" action="" method=""> <input type=" ...
- 一些CMS网站系统漏洞,练手用(持续更新)
仅供拿shell,提权测试用,请勿恶意破坏 XuSoft系统: 后台万能密码:'or'='or' 可直接登陆,后台地址 /manage/login.asp inurl:ReadArticlemb.a ...
- Django Web在Apache上的部署
1. 安装配置Apache 2. 安装wsgi_mod模块 3. 开放相应端口 vim /etc/sysconfig/iptables # Firewall configuration written ...
- Binding在WPF中的使用
闲来无事,不想打DOTA,在这里小小研究下wpf中关于Binding的东西. 咯咯 在我们印象中,Binding的意思是“绑定”,这个“绑”大概取自于Bind这个单词吧,这么理解的话就是以音译英了,没 ...
- 在Site Settings下找不到Navigation标签
有时候我们可能找不到Navigation标签, 仅仅在Look and Feel下面看到"Quick launch" 如何才能找到我们想要的"Navigation&quo ...
- iscc2016-basic-find-to-me
额 第一题就暴力搜索了 已知仿射加密变换为c=(11m+8)mod26,试对密文sjoyuxzr解密 #include <stdio.h> int main(void) { int m,c ...
- ubuntu 查本机 ip地址的命令是什么, 详细信息的?
使用ifconfig命令即可.你一敲进去都出来了