bzoj2296【POJ Challenge】随機種子
題意:
求一個≤10^16的數,使這個數包含123456789且為x的倍數。x≤1000000。
題解:
16-6剛好等于10。是以我們可以直接讓所求的數的前10位為1234567890,則隻要求出1234567890000000加上什麼≤1000000的數可以為x的倍數即可,而這個可以很容易求出。
代碼:
1 #include <cstdio>
2 #include <cstring>
3 #include <algorithm>
4 #define inc(i,j,k) for(int i=j;i<=k;i++)
5 using namespace std;
6
7 const long long a=1LL*1234567890*1000000;
8 int t; long long b;
9 int main(){
10 scanf("%d",&t); inc(i,1,t){scanf("%lld",&b); if(b)printf("%lld\n",a+b-a%b);else puts("-1");} return 0;
11 }
20160905
轉載于:https://www.cnblogs.com/YuanZiming/p/5861795.html