【题目链接】
https://www.lydsy.com/JudgeOnline/problem.php?id=2296
【题解】
前十位用来保证
出现过,后
位用来保证这个数是
的倍数。由于
所以一定有解。
时间复杂度
。
【代码】
/* - - - - - - - - - - - - - - -
User : VanishD
problem : [bzoj2269]
Points : O(1)
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define ll long long
# define inf 0x3f3f3f3f
using namespace std;
int read(){
int tmp = 0, fh = 1; char ch = getchar();
while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
return tmp * fh;
}
int main(){
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ll lim = 9876543210000000ll, les;
for (int opt = read(); opt > 0; opt--){
int tmp = read();
if (tmp == 0){
printf("%lld\n", -1ll);
continue;
}
les = lim % tmp;
if (les == 0) les = tmp;
printf("%lld\n", lim + (tmp - les));
}
return 0;
}