3052: [wc2013] Candy Park time
limit: $ Sec
Memory Limit: MB
Submit: 892
Solved: 425
[Submit] [Status] [Discuss]
DescriptionInputOutputSample InputSample InputSample Output8413127-HINTSource
[Submit] [Status] [Discuss]
A combination of Bzoj 2120 and Bzoj 3757.Note that when sorting the first keyword is the block where the left endpoint resides, the second keyword is the block where the right endpoint resides, and the third keyword is the time of the most re
Zoj 3435Test instructionsGive 3 number a,b,c, define a cube, the cube has a*b*c points, the coordinates of each point is an integer (x, Y, z), the coordinates (1,1,1) and any other point (X1,Y1,Z1) of the different lines have how many bars.Limitations:2 ideas:There are 3 types of cases:1. X1,Y1,Z1 is greater than or equal to 2:The question becomes 1 Use Möbius inversion to do.Set F (k) as the number of triples (x, y, z) of gcd (x, Y, z) =k,Set F (k) to GCD (x, Y, z) as a multiple of K (x, Y, z),
Topic Link: 51nod 1244 the sum of the function of the MORecommended Learning Blog: http://blog.csdn.net/skywalkert/article/details/50500009 and then, this method mentioned, I do not play the formula,,, good look at the great God's blog Alas OrzThe Pre-n^ (2/3) was pretreated by sieve method, and then the memory search solution was followed. Don't hash it out, use map first.Tonight self-study feel dizzy, free I still have to practice other problems Orz1#include 2#include 3#include 4#include 5#inc
to the front, the rest of the piece can handle the prefix and do O (1), the front and then divide the block, do O (sqrt (n))Wt:How to find G (T) =σ{p| T IsPrime (P)}miu (t/p)
Act 1.
You just need to enumerate every prime force.
Because of the conclusion of 1/1+1/2+1/3+...+1/n=o (LOGN), each prime number is enumerated when it is averaging O (LOGN).
And prime numbers happen to have O (N/logn), so the brute force enumeration is O (n).
Act 2.
Linear sieve
#include
products (multiples of 36, multiples of 100,...) -...Pit point:Check in the calculation of the time will explode int, pay attention to open longlong (really didn't notice at the beginning)Pay attention to the range of the two points (this problem is completely 1~2*k)Code#include #include#include#include#includeusing namespacestd;intRead () {intx=0, f=1;CharCh=GetChar (); while(ch'0'|| Ch>'9') {if(ch=='-') f=-1; Ch=GetChar ();} while(ch>='0' ch'9') {x=x*Ten+ch-'0'; Ch=GetChar ();} returnx*F;}i
inverse element in convolutional sense is called the Möbius function. Which means satisfyingThe only number-theoretic function.Write this expression open............ (*)Typically, the Möbius function is defined as;, if it can be written as a product of different primes;, in other cases.According to this definition it is not difficult to prove (*) formula.For, (*) Form;For, with the basic theorem of arithmetic to writeSoNow, what is Möbius's anti-speech?When and only ifIn other words,Prove:Inste
The main topic: several times asked how many pairs (x, y) meet AFirst, the problem of inquiry decomposition is converted to the number of pairs (x, y) satisfying xHere you can use the inverse of the Uffizi:We make F (d) gcd (x, y) =d and the logarithm of xF (d) for d| GCD (x, y) and number logarithm of xSo obviously there is f (d) = (n/d) * (M/D)But the direct formula is still O (n^2) levelConsidering that (N/D) * (M/D) There will be at most only 2√n vendors so we can enumerate this quotient to
Main topic:Take a number from 1~b as x, and a number in the 1~d as YHow many kinds of gcd (x, y) = k are madeHere we can use the Möbius function to solve the problem.The formula used here is [gcd (x, y) ==1] =σ (DEL|GCD (x, y)) Mu (del)Σ (1=σ (1=σ (1=σ (11#include 2#include 3#include 4 5 using namespacestd;6 #definell Long Long7 #defineN 1000108 intMu[n], prime[n];9 BOOLCheck[n];Ten One voidGETMU (intN) A { -memset (check,0,sizeof(check)); -mu[1] =1; the inttot =0; - for(intI=2; I){ -
Everything starts hard.When I was in college, I thought I was a literary teenager, writing a song and writing a diary. After work seems to have not written, and now want to write a few words need to grasp the heart scratching the cheek, this log is basically finished.First introduce oneself, my name Ringling, is a male program ape, Liaoning Dalian people, so far single. In 13 after graduating from Shenyang to work so far, there are now to go to the North wide-depth of the plan, want to engage in
The main topic: Beg Σ[i|n]i^dOnlookers: http://www.cnblogs.com/jianglangcaijin/p/4033399.htmlSure enough, I'm still too konjac--In addition, the 0 items of σ[1#include Bzoj 36,011 person's number theory of the Mo-de-si inverse + Gaussian elimination
: gives A,b,c,d,k, which makes a1 Set F (k) for gcd (x, y) =k number pairs (x, y) logarithm, we require f (1)2 set F (k) is gcd (x, y) is a multiple of the number of K (x, y) logarithm, can think of f (k) = Floor (b/k) *floor (d/k), F (k) =e[b/k]*[d/k]*mu[k];3 the Möbius was reversed by: 4 Order lim=min (b/k,d/k)5 F (1) =mu[1]*f (1) + mu[2 ]*f[2] + ... + mu[lim]*F (Lim)6 because (N1,N2) and (N2,N1) are counted in the same situation, the final result is also to reduce the duplication of the s
nThe complexity is probably O (n*sqrt (n) *log2 (n)), but can be violent to raise points, and then back to the statistics, then O (1) answer, but N is no longer able to solve the big, even if the n#include HDU 5273 Dylans loves sequence (interval inverse logarithm-mo team algorithm)
The Great God:http://blog.csdn.net/u014800748/article/details/47680899The sum of GCDTime limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)Total submission (s): 526 Accepted Submission (s): 226Problem Descriptionyou has an arrayThe length ofIsLetInputthere is multiple test cases. The first line of input contains an integer T, indicating the number of the test cases. For each test case:First line have one integersSecond Line hasIntegersThird line have one integersThe numb
right. As the example isGCD (*3*3+GCD) *3*3 + gcd (1,4) *3*3) ...........How to calculate the corresponding interval number of each GCD?It is possible to know that the GCD from the dividing line to both sides is decremented. Assuming that G is the gcd of [L,r], then for [L-1,r] only gcd (g,num[l-1]) is calculated.Then the GCD hypothesis is the same as that of G. Otherwise, a new value is added.Analysis of Complexity:For each paragraph, the total GCD and the number of O (n) are calculated.The lo
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.