[BZOJ2296] Random seed

Source: Internet
Author: User
Tags random seed

Given a number n of [0,1e6], the need to construct a number m, so that M is a multiple of n, M belongs to [0,1e16] and M contains all the numbers [0,9]

If not present, output-1

Output-1 when n=0

When n belongs to [1,1e6]

M= (9876543210*1e5+n)-(9876543210*1e5+n)%n

Thus, the first 10 bits of this number will not change, so there is a guaranteed [0,9], minus the remainder of the modulo n so that it can be divisible, the number of bits exactly

When N=1e6 is using the above construction method the number of bits will be super, but only with the output 9876543210*1e5 on the line,,,

1#include <bits/stdc++.h>2 using namespacestd;3 Const Long Longmust=9876543210000000;4 intMain () {5     intT;6     Long LongN;7scanf"%d",&T); 8      while(t--){9scanf"%lld",&n);Ten         if(!n) puts ("-1"); One         Elseprintf"%lld\n", (Must+n)-(must+n)%n); A     } -     return 0; -}
View Code

[BZOJ2296] Random seed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.