Xiao Ming is a clever boy and has a strong interest in number theory. He found that it was difficult to ask how many primes between 1 and 10n, and it was difficult to determine the size of the N value. Now the question is, tell you the value of N, let you help xiaoming calculate the number of primes less than 10n total number of bits?InputThe input data has several groups, each set of data contains 1 integers n (1 Outputcorresponding to each set of data, the number of digits less than 10n is out
Title Address: HDU 3944Test instructions: Tell you in a point in the Yang Hui triangle (row N m column), ask you to go from (0,0) point to the point passing through the points of the least weight and (can only go down or oblique walk). At the same time, the prime number p takes the remainderIdea: According to the known point (n,m), if N/2 >= m, then from the known point, you can go straight to the direction of the oblique, until the boundary, then the weight and C (n,m) +c (n-1,m-1) .... C (n+1,
Bayesian statistics are based on conditional probability, joint probability, so we start with probability, conditional probability, joint probability, then Bayesian theorem, and finally a Bayesian application--spam filteringProbability: The likelihood of an event occurring, such as tossing a coin, the likelihood of a positive upward being 50%, and the probability of a dice point of 6 being 1/6. We use the notation as P (A)Conditional probability: sati
24 8011 2 36 20 76Sample outputcase 1:341case 2:5,996Authordigiter (Special Thanks Echo)Source2010 acm-icpc multi-university Training Contest (+)--host by Bjtu idea, not coprime China remainder theorem, no solution output-1, has a solution to output a minimum positive integer (positive positive ...) Important things to say three times) that is the answer to the question of 0 when you need to output least common multiple; code:#include #include#includ
know the end of a line with what ended, but changed to as long as not equal to the end of the space, it can be.The maximum number of missiles to intercept is easy to understand, which is to find the longest non-incrementing subsequence.Minimum number of systems to be equipped, at first I thought as long as the latter number is larger than the previous one, and then C + +, the last thing to get is the number of systems to be equipped.But 7 8 9 2 1 3 4 5 These few numbers will not be able to get
Title Address: http://acm.hdu.edu.cn/showproblem.php?pid=5446Idea: Lucas find out all A[i]=c (n,m)%m[i], the Chinese remainder theorem to find the final result X (Ll*ll will explode, handwritten multiplication).Chinese remainder theorem:Set m1,m2,....mn is a positive integer of 22 coprime, for any given integer A1 , a2,....an must have integers to satisfy x ≡a1 (mod m1), x≡ a2 (mod m2) ,x≡a 3 (mod m3) ...and satisfies the solution of the ab
Transmission Doorn * n Squares, draw a line from top left to bottom right. A robot moves from top to bottom to the right and can only go right or down. and ask only on the line above or below to walk, cannot cross this line, how many different way? Because the number of methods can be large, you only need to output mod 10007 results.InputEnter a number n (2 OutputThe number of output methods Mod 10007.Input example4Output example10Problem Solving Ideas:From the top left to the right can only pro
Using the Bayes theorem, the most important thing at the moment is the hypothesis. is the unknown event known, but also to pay attention to the hypothesis of the whole process, can not start a new hypothesis, this assumption is often not comprehensive.I found it myself. There are two kinds of hypothetical methods, one is naming and the other is timing. The whole process is reflected in the timing, assuming that the scope of consideration should start
Test instructions: C (p,q)/C (r,s), 4 numbers are less than 10000, the answer is not greater than 10^8Idea: According to the scope of the answer guess, do not need to use high precision. According to the unique decomposition theorem, each number can be decomposed into a number of primes multiplied. First, all the primes within 10000 are calculated, and the exponent of each molecule part is calculated by using a array to represent the index of the prim
Transmission DoorThinking of solving problemsExtension $CRT? $, that is, the Chinese remainder theorem in the case of the modulus is not coprime, first for the equation? $\begin{cases} x\equiv a_1\mod m_1\\x\equiv a_2\mod m_2\end{cases}$, it can be written as:$\begin{cases} x=k_1*m_1+a_1\\x=k_2*m_2+a_2\end{cases}$Then simultaneous equations:? $k _1*m_1+a_1=k_2*m_2+a_2$$\leftrightarrow-k_1*m_1+k_2*m_2=a_1-a_2$A in this case the form is very similar to
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5768Give you n equations of congruence, and then give you l,r, and ask you how many numbers%7=0 and%ai! = Bi in L,r.The more obvious Chinese remainder theorem + tolerance, the time to add a (%7=0) this group.The middle will explode longlong, so add a fast multiplication (like a matrix fast power). Because the normal a*b is added directly to a B, it is likely to explode. But you can split B into bin
), here to use the theorem, not repeat count, there is no omission, the formula:AC Code:1#include 2 using namespacestd;3typedefLong LongLL;4 intt,cnt,prime[ the]; LL A,b,n;5ll solve (ll x) {//the total number of coprime with n6 intNum LL ans=0, TP;7 for(intI=1;i1//using the binary to indicate whether each mass factor is used, that is, there is a 2^cnt-1 species may, at this time CNT smaller, the topic of 1e9 up to 8 factor, the binary optimiz
5Sample Output33HintHintfor Sample 1, squirrels would put no more than 2 beans in one tree. Since trees is 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 beans in tree 1 and put 1 beans in tree 2.Source2009 multi-university Training Contest 13-host by hitsNaked Lucas theorem, the function can be called directly.I don't un
can are both types of C Arpets and their sides are: {2, 6} and {3, 4}.InputInput starts with an integer T (≤4000), denoting the number of test cases.Each case starts with a line containing the integers: ab(1≤b≤a≤1012) where a den OTEs the area of the carpet and b denotes the minimum possible side of the carpet.OutputFor each case, print the case number and the number of possible carpets.Sample Input200a212 2Sample OutputCase 1:1Case 2:21. How many approximate numbers are there:First decompose f
mod 5 = 4x MoD 7 = 6Han Xin is based on this equation set, the value of x is solved.Little hi: Well, that's it! We generalize this equation group to the general form: given n group Divisor m[i] and remainder r[i], the N group (M[i],r[i]) solves an X, making x mod m[i] = r[i]. Little ho: How do I feel that this equation set has a fixed solution?Small hi: This equation group is called the modular linear equations. It does have a fixed workaround. But before I tell you the solution, why don't you
attention to i*i== n the case of the standard algorithm is the application of a positive integer unique decomposition theorem, will be the only decomposition of N, all of its factors and is actually (a1^0+a2^0 ...) (A2^0 ...) ...... That is, the combination of various permutations, and because it does not contain itself, so the last minus N; code:#include #include#include#include#includeusing namespaceStd;typedefLong Longll;Const intmaxn= +;//BOOLvis
3040 China remainder theorem 1time limit: 1 sspace limit: 32000 KBtitle Grade: Bronze BronzeTitle DescriptionDescriptionExcerpt from an Introduction to algorithms ...The number of the remainder is 2,3,2 when the first k is 3,5,7 removed;Enter a descriptionInput DescriptionA number k.Output descriptionOutput DescriptionFind the number of K qualifying.Sample inputSample Input1Sample outputSample Output23Data range and TipsData Size Hintk>=1;The answer
Problem Solving Ideas:Direct C (n+m, m)% p, because n, M, p are very large, so we should use the Lucas theorem to solve the problem of large combination number of modulus.#include HDU 3037 Saving Beans (direct application of Lucas theorem)
Reprint Please specify source: http://www.cnblogs.com/fraud/--by fraudZball in Tina townTime limit:3000/1500 MS (java/others) Memory limit:262144/262144 K (java/others)Total submission (s): 219 Accepted Submission (s): 144Problem Descriptiontina Town was a friendly place. People there care on each of the other.Tina has a ball called Zball. Zball is magic. It grows larger every day. On the first day, it becomes1 time as large as its original size. On the second day,it would become 2 times as larg
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.