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
that size.
Sample Input
4245231
Sample output
1 2 52 4 133 5 214 231 32549
SourceGreater New York 2006
Mean:
In the first quadrant, enter N, and then count the number of viewpoints in the range of (0
The so-called viewpoint can be reached (x1, Y1) starting from (0, 0) without any point of intersection in the middle.
Analyze:
Through analysis, we will find that as long as X and Y are mutually qualitative, (x, y) is the viewpoint. We only need to o
;Ideas:Note that the number is within 1000, so the combination of all to find out, but the number is huge so the same to be compressed;AC Code:#include #include#include#includeusing namespaceStd;typedefLong Longll;ll dp[1003],num[1003],p[1003][1003];intn,a[1003];Constll mod=1e8+7;//Note is 8, the time of the game this place direct wa to cryintgcdintXinty) { if(y==0)returnx; returnGCD (y,x%y);}intMain ()
Question: There are N nodes in the circle, and a node in the center is connected to N nodes. There are 2 * N edges in total and N edges are deleted, to connect N + 1 points, the same rotation is considered equivalent. How many situations are there.Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 2481It is said that there was only one Tsinghua team in the competition. Very comprehensive, mainly because the recursive part is hard to think about.Good questions, difficult !!!!!!!!!!!Practice from AC
Bzoj mathematical Number Theory
Question: Find 1 ~ N! Medium and M! Ensure n> M.
I hate mathematics most...
Idea: n> M is ensured, so n! It must be m! . If an X is found to make gcd (x, M !) = 1, then gcd (x + M !, M !) = 1 must be true, gcd (x + K * m !, M !) = 1 (k> = 1) is also valid. The number of X is PHI (M !), Then the total
"Test Instructions" for the given a,b,c, put a number of weights on the left side of the balance, put a number of weight B weights on the right side of the balance, so that the balance at both ends of the weight difference is c. Set X a weight and y b weights to find the minimum value of x+y."Algorithmic" number theory
XOR equation
The positive integers A and B have a sum of s and a bitwise XOR of x. How many possible values is there for the ordered pair (a, b)? Input
The first line of the input contains integers s and x (2≤s≤1012, 0≤x≤1012), the sum and bitwise XOR of the PAI R of positive integers, respectively. Output
Print A single integer, the number of solutions to the given conditions. If no solutions exist, print 0. Examples input Copy
9 5
Output
4
Input Cop
,Y0) General Solution: x=x0+ (b/d) K, y=y0-(A/DK) is to try to get the positive and negative mutual cancellation, ( true • Primary School Olympiad content)Doubts: Most beginners may have such a question (anyway I have just learned), to solve the equation is ax+by=m, and the above algorithm is the solution of AX+BY=GCD (A, B)In fact, AX+BY=GCD (A, b) can become AX*K+BY*K=GCD (A, b) *k, so that gcd (a, b) *k=m, find K, and then X*k is the solution of ax+by=m. 5 , multiplication inverse elementLe
to) a hole to catch the rabbit, ask the rabbit finally can escape a robbery. For example, there are n=6 a hole, the number is 0, 1, 2, 3, 4, 5, the wolf every m-1=1 a hole to catch the rabbit, then the wolf into the cave is 0, 2, 4, 0, 2, 4 ... (infinite loop). If rabbits hide in holes 1, 3 and 5th, they are safe.Sample Input2//Number of test cases1 2//m and N2 2Sample OutputNOYES#include using namespacest
Topic Links:Codeforces 201AMain topic:Give an X, to find a square matrix of the smallest side length, the matrix is 01 matrix, and meet the elements up and down symmetry, left and right symmetry, asked to construct the number of 1 is the smallest matrix of x side length is how much.Topic Analysis:
First we can see that if the maximum number of n-1 constructs is greater than the maximum
analysis and observation, then we only need to be a certain number of each number of times to appear, and then calculate the sum of this bit, because each one on the total and are the same, It is only necessary to solve the rounding and 10 of the multiply to ensure the digits. It is worth mentioning that the data of this topic is very big, the variable that stores the answer is best to use unsigned long lo
1 int judge (int* X) {2 x[2]/= gcd (x[2], x[1]); 3 for (int3; I 2]/= gcd (x[i], x[2]); 4 return x[21; 5 }This algorithm is called Euclidean algorithm. will not overflow, because
gcdThe number of recursive layers of a function does not exceed4.785lgN+ 1.6723ItsInN=max{a,b}。LetgcdThe highest number of recursive layers isgcdF n , F n -1). The GCD can also be used to find the least common multiple LCM
); * for(intI=1; i) $ {Panax Notoginseng if(cnt[i]==cnt[i-1]) - { theans++; + if(ans==k) A { theprintf"%d", Cnt[i]); + return 0; - } $ } $ Elseans=1; - } - the return 0; -}View Codemore about the bezout theorem
In number theory, the Bezout theorem is a t
needs to calculate the prime number within 1E7 and then take the highest of each prime power-1, you can find out the situation of n=1e14 but still will be TSince the answer to a continuous n is the same for all to simulate the process (the conclusion here is that the value of the LCM is not changed when a new prime number of the highest power is present)2 13 14 28 49 1216 2425 120Prime^num anw[on a]*primeb
, only one of themA contained factor does not affect the greatest common divisor. Specifically, when k=2, the description calculates aWhen even and an odd greatest common divisor, you can divide the even number by 2.Algorithm process:1, if an=bn, then an (or Bn) *CN is greatest common divisor, the algorithm ends2. If an=0,bn is greatest common divisor, the algorithm ends3. If Bn=0,an is greatest common divisor, the algorithm ends4. Set A1=a, B1=b and
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.