D. Maximum Value time limit per test 1 second memory limit/test 256 megabytes input standard input output standard out Put
You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder Ai divided by AJ), where 1≤i, J≤n and Ai≥aj. Input
The contains integer n-the length of the sequence (1≤n≤2 105).
The second line contains n space-separated integers ai (1≤ai≤106). Output
Print the answer to the problem. Samp
2^X mod n = 1Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 13341 Accepted Submission (s): 4143Problem descriptiongive a number n, find the minimum x (x>0) that satisfies 2^x mod n = 1.Inputone positive integer on each line, the value of N.Outputif the minimum x ex
Time Limit: 2 seconds memory limit: 65536 KB
Give a number N, find the minimum X that satisfies 2 ^ x mod n = 1.
Input
One positive integer on each line, the value of N.
Output
If the minimum x exists, print a line with 2 ^ x mod n = 1.
Print
2^X mod n = 1Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 14349 Accepted Submission (s): 4438Problem descriptiongive a number n, find the minimum x (x>0) that satisfies 2^x mod n = 1.Inputone positive integer on each line, the value of N.Outputif the minimum x ex
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 13952 ^ x mod n = 1
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 12146 accepted submission (s): 3797Problem descriptiongive a number N, find the minimum x (x> 0) that satisfies 2 ^ x mod n = 1.
Inputone positive integer on each line, the value o
This question requires the smallest positive integer x, N> 0 that satisfies 2 ^ x limit 1 (mod N.
First consider the Euler's Theorem 2 ^ Eular (n) limit 1 (mod N), which requires n> 1. So when n = 1, in fact, all K numbers have k limit 0 (mod N), which is a special decisio
/*2 ^ x mod n = 1Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 11800 accepted submission (s): 3673Problem descriptionGive a number N, find the minimum x (x> 0) that satisfies 2 ^ x mod n = 1.
InputOne positive integer on each line, the value of N.
OutputIf the min
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 13345 Accepted Submission (s): 4146Problem descriptiongive a number n, find the minimum x (x>0) that satisfies 2^x mod n = 1.Inputone positive integer on each line, the value of N.Outputif the minimum x exists, print a line with 2^x
2 ^ x mod n = 1
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 11542 accepted submission (s): 3577
Problem descriptiongive a number N, find the minimum x (x> 0) that satisfies 2 ^ x mod n = 1.
Inputone positive integer on each line, the value of N.
Outputif the
2^X mod n = 1Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 13610 Accepted Submission (s): 4208Problem descriptiongive a number n, find the minimum x (x>0) that satisfies 2^x mod n = 1.Inputone positive integer on each line, the value of N.Outputif the minimum x exi
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) Total Submission (s): 14494 Accepted Submission (s): 4484Problem descriptiongive a number n, find the minimum x (x>0) that satisfies 2^x mod n = 1.Inputone positive integer on each line, the value of N.Outputif the minimum x exists, print a line with 2^x
Question:
Returns a positive integer n, and returns the smallest x so that 2 ^ x mod n = 1.
Ideas:
N = 1. All positive mod 1 values are 0.
N is an even number, why? The above formula can be deformed as follows: 2 ^ x = k * n + 1. If n is an even number, k * n + 1 is an odd number, and
In this question, 2 ^ X is obtained cyclically and then mod n = 1, and the time exceeds.
Use mathematical formula (M * n) % d = (M % d * n % d) % d to simplify the scenario.
The Code is as follows:
# Include
Strategy: we can see that the remainder is not equal to 1 or the number that can be divisible by 2. We only need to judge whether it is an odd number other than 1, search for 2 ^ X (mod (N) in sequence ))? = 1.Difficulty: if every time it is based on the original × 2, it will time out. At this time, we can use the same
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.