Hdu 5072 Coprime (number theory), hducoprime
Link: hdu 5072 Coprime
Given the number of N, ask how many 3 tuples can be selected, or [(a, B) = (B, c) = (a, c) = 1] or [(a, B) =1 and (a, c) =1 and (B, c) =
1].
Solution: You can change the angle of this question to think of three numbers as three sides of a triangle. The mutual quality means that the color of the s
Link: HDU 5072 Coprime
Given the number of N, ask how many 3 tuples can be selected, or [(a, B) = (B, c) = (a, c) = 1] or [(a, B) =1 and (a, c) =1 and (B, c) =
1].
Solution: You can change the angle of this question to think of three numbers as three sides of a triangle. The mutual quality means that the color of the side is 1. Otherwise, the value is 0.
Number of triangles with the same color as the three
Euler's function:
Euler's function is a very important function in number theory. Euler's function refers to the number of positive integers (including 1) with a positive integer N, less than N and interlace with N, it is recorded as PHI (n ).
Complete remainder set:Defines a set of numbers less than N and with N mutual quality as Zn, and calls this set a comple
modulo p.
Sample Input
21 2 52 1 5
Sample output
33HintHintFor sample 1, squirrels will put no more than 2 beans in one tree. Since trees are different, we can label them as 1, 2 … and so on. The 3 ways are: put no beans, put 1 bean in tree 1 and put 2 beans in tree 1. For sample 2, the 3 ways are: put no beans, put 1 bean in tree 1 and put 1 bean in tree 2.
Source2009 multi-university training contest 13-hostBy hit
Recommendgaojie
A very powerful number
GCDTime limit:6000/3000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 5454 Accepted Submission (s): 1957Problem Descriptiongiven 5 integers:a, B, C, D, K, you ' re-find x in a...b, y in c...d that GCD (x, y) = K. GCD (x, y) Me Ans The greatest common divisor of x and Y. Since the number of choices may is very large, you ' re only required to output the total number of diff
equivalent toGCD (A-B) > 1 equivalent toGCD (2 * A, A + b) > 1Because A+b is odd.Equivalent toGCD (A, a +b) > 1 is equivalent toGCD (A, B) > 1Deduction EndThe following is a decomposition of the factorization, find the n number of different parity and meet gcd (A, B) > 1 numberThe number of the last plus parity is the answer.Therefore, the number of 1~MAXN and A
of cats (the one in height) to clean the room, find out the number of cats that do not need to clean the room and the total height of all cats.
Solution:
Input H, W.
Set K as the number of layers, Layer 1, Layer 2 ,....
Height: H/(n + 1) h/(n + 1) ^ 2 H/(n + 1) ^ 3 H/(n + 1) ^ 4 ...... H/(n + 1) ^ x = 1
Amount: 1 N ^ 2 N ^ 3 N ^ 4 ...... N ^ x = workers
① H * (1/(n + 1) ^ k = 1; → ③ H = (n + 1) ^ K;
② N ^
; M = M' * k => X = K' * m + A = K' * K * m' + K * a' = K * (K' * m' + '); therefore, gcd (x, m) = k> 1. Likewise, if gcd (B, n)> 1, then gcd (x, n)> 1. Therefore, it is necessary for a and M * n to communicate with each other and B and N to communicate with each other.3) Next we will prove the adequacy: from X % m = A, we can get x = K * m + A; from the Euclidean algorithm, we can find the process of maximizing the common number (no proof, huh, huh,
prime[j] multiplied by whether I can be divisible prime[j], if possible, prove I*prime[j] has a prime[j] this factor, if not, then the number of its quality factor will be on the basis of the number of the I of the qualitative factor + 1Code#include using namespacestd;#defineN 1000100#defineMX 1000010#definell Long Longll T,n,cnt,c,k,mm;ll S[n],f[n],v[n],num[n],prime[n];voidPrimesintN) {num[1]=1; for(intI
gold plates you have obtained)
He knows that there are many places of interest in China. He knows that he cannot play all places in the T1 to t2 days, so he decided to designate two places V1, V2, if the contestant can calculate the total number of steps from V1 to v2 in the T1 to t2 days (including t1 and t2) (each road takes one day, and cannot stay in a city, and when T1 = 0, the number of walk is 0), t
Just list some of the mathematical theorems that have been used in the problem, and make a partial arrangement.1. The number of digits of N:LOG10 (N)2, N is prime number:A^m = a^ (m% (n-1)) (mod n)3, Euler function:The number that is smaller than the number of equals n, and n coprime number. Euler function Expression
≤n-2 and1:a^tmodn=12: Existence of integer i,0When n is a prime number, any A in 2 and n-1, a belongs to set B (n)When n is composite, if a belongs to set B (n), then n is a strong pseudo-prime number based on a (base), and a strong pseudo-evidence of N primality is called.N is a prime number, indicating that it is a strong pseudo prime for all the bottomBtest (a
Question: "I don't know the number of things today. There are two things left in three, three in five, three in five, and two in seven. Ask ry ?"
According to today's statement: divide a number by 3 + 2, divide by 5 + 3, divide by 7 + 2, and find this number...
At present, I still don't understand Sun Tzu's theorem (China's surplus theorem). So I will give my own
A new change problem
Time Limit: 5000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)Total submission (s): 533 accepted submission (s): 265 Problem descriptionnow given two kinds of coins a and B, which satisfy that gcd (a, B) = 1. here you can assume that there are enough coins for both kinds. please calculate the maximal value that you cannot pay and the total number that you cannot pay.
Inputthe input will consist of a series of
Ultraviolet A 11256-repetitive multiple
Question Link
Find a minimum value that is equal to a multiple of N and a repeating number (according to the definition in the question)
Train of Thought: if it is a repeated number, the form must be a number of the corresponding digits in the form of 100010001, so you can enumerate such numbers, and N to take GCD, if the
Ultraviolet A 1521-GCD guessing game
Question Link
Assume that the number X is between 1 and N. Now, you can guess the number a, tell the answer to gcd (X, A), and guess the number several times in the worst case.
Idea: In terms of prime numbers, you can guess the numbers composed of these prime numbers by guessing the product of a group of prime numbers. The ans
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.