#include <bitset>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
#include <iterator>
#include <queue>
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
const int maxn = 111111;
char s[maxn];
int arr[maxn];
int main() {
int len, i, j, o;
int T;
scanf("%d", &T);
while (T--) {
scanf("%s", s);
len = strlen(s);
j = 0;
o = len - 1;
memset(arr, 0, sizeof(arr));
for (i = len - 1; i >= 0; --i)
arr[j++] = s[i] - '0';
while (true) {
arr[0]++;
for (i = 0; i < o + 3; ++i) {
if (arr[i] >= 10) {
arr[i + 1]++;
arr[i] -= 10;
}
else
break;
}
int r = 0;
for (j = 0; j < o + 3; ++j) {
r += arr[j];
if (r >= 10)
r -= 10;
}
if (r == 0)
break;
}
len = o + 3;
while (len > o && arr[len] == 0)
--len;
for (i = len; i >= 0; --i)
printf("%d", arr[i]);
puts("");
}
return 0;
}
HDU 4608
最新推荐文章于 2018-11-26 20:28:17 发布