【BZOJ2296】随机种子(构造)

problem

给出 T 组询问,每组询问一个 x ,求出一个数,满足:
1)是 x 的倍数
2)十进制下答案包含 0∼9 中的所有数字

x <= 10 ^ 6
要求答案 <= 10 ^ 16

solution

前 10 位为 1234567890
假设 1234567890 000000 % x = A
后6位为 (x-A)%x(减掉余数,,肯定是x的倍数。)

codes

#include<iostream>
using namespace std;
typedef long long LL;
LL t = 1234567891000000;//1000000-余数前10位一定是那啥。。。
int main(){
    int _w;  cin>>_w;
    while(_w--){
        LL x;  cin>>x;
        if(x==0)cout<<-1<<'\n';
        else cout<<(t-t%x)<<'\n';
    }
    return 0;
}
posted @ 2018-05-25 20:31  gwj1139177410  阅读(98)  评论(0编辑  收藏  举报
选择