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");
}
}
上一篇:nginx安装配置域名转发


下一篇:qt 实现钟表图标