[bzoj2296][POJ Challenge]隨機種子【構造】
阿新 • • 發佈:2019-01-10
【題目連結】
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;
}