Turn off the lights on the lights

Source: Internet
Author: User

Http://www.cnblogs.com/haolujun/archive/2012/10/10/2719031.html

There is a number 1~100 a light bulb, at first all the lights are extinguished. There are 100 students to press the lamp switch, if the light is bright, then press the switch, the lantern will be extinguished. If the lamp is off, it is lit after pressing the switch.

Now start pressing the switch.

The 1th classmate, all the light bulb switch is pressed once (by the number of the switch lamp: three-and-three,...... 100).
2nd classmate, one lamp at a time (press the number of the switch light: 2,4,6,......, 100).
3rd classmate, two lights at a time (press the number of the switch light: 3,6,9,......, 99).
......

The question is, how many lights are lit after the 100th student has pressed?

There is a mathematical solution to this problem. It can be seen that the light bulb that has been pressed for odd times should be on, and the light bulb that has been pressed even a few times should be extinguished. So what kind of bulb has been pressed for odd number of times? What kind of bulb has been pressed even several times? From the process can be found that if a lamp number has an even number of factors, then the lamp is pressed an even number of times, and vice versa by an odd number of times. Now the question becomes, what kind of number has an odd number of factors, what number has an even number of factors? This involves a theorem called the factorization of a mass factor, presumably meaning that any positive number can be uniquely expressed as a multiple-factorization-power product.

For example:

14=2*7
50=2*5^2
...
100=2^2*5^2

That is n= (p[1]^e[1]) * (p[2]^e[2]) *......* (P[k]^e[k]), where p[i] is prime, e[i] is the power of p[i]. By this formula we can also derive a formula for how many factors a number has: Factornumber (N) = (e[1]+1) * (e[2]+1) *......* (e[k]+1).

So what is the condition that satisfies factornumber (N) is odd? It is clear that all E[1],e[2],......, E[k] must be an even number in order to ensure that the e[i]+1 is odd and the result is an odd number. And because E[1],e[2],......, e[k] are even, then N must be a complete square (because sqrt (N) = (p[1]^ (E[1]/2)) * (p[2]^ (E[2]/2)) *......* (p[k]^ (E[K]/2)) is an integer ) 。 Back to the problem of light bulb, 1~100 in the total square number of 1,4,9,16,25,36,49,64,81,100 these 10 numbers, that is, the last only number of these 10 number of lights are lit.

This explains Factornumber (N) = (e[1]+1) * (e[2]+1) *......* (e[k]+1). Why is f (N) equal to all E (i) +1 multiplied,

The n is decomposed by a mass factor. Without losing generality, suppose N=x^a * y^b * z^c * ... x^a represents a power of X. Then the approximate sum of n equals x (0 power, 1 power, ..., a power), Y take (0 power, 1 power, ...), Z take (0 power, 1 power, ... ....), C power), ..., and so on.------- The number of its approximate numbers equals (a+1) * (b+1) * (c+1) * .... When all indices are 0, the approximate number is 1, and when all the indices take maximum, it is n itself.

If you want to make an odd number of numbers, then a,b,c, ... Must be even, that is, n must be a full square number.

20 = 1*2^2*5^1;

20 = 1*20=2*10=4*5 are paired, 20 of the number of constraints = 3 (2 of the exponent +1) * * (5 of the Index +) = 6

36 = 1*36=2*18=3*12=4*9=6*6 The total square number is not a pair, but a singular occurrence.

~ As the first floor says, the question is to examine the parity of the number of factors in each number of 1~100. There is an odd number of factors of the lamp state and the initial state of the different, conversely, the factor is an even number of, the state of the lamp is unchanged. For two examples: the 2nd lamp has 1 and 22 factors (2=12), so the switch two times, and so on, and so on, the 4th lamp has 1, 2, 43 factors, (4=14=22) by three times, and the initial state is different, that is, the beginning of the lamp is extinguished, the end of three times the light is lit.
Why do you cite these two examples? There is a reason, hehe. We notice that the factor of each number is in pairs, for example, each number is at least 1 and it itself (1 is a special case, 1 is itself) two factors, such as 36 of the factor 1 and 36,2 and 18,3 and 12,4 and 9, are paired. Therefore, when and only if, in a number of the pair appear in the same two factors, (such as the above Example 4 has 2
2 this pair of factors), that the number can be prescribed is an integer, its number of factors will become odd.
So can have the following conclusion, the root result is the number of integers (lights), the last is bright, that is, the number is 1 square, 2 square, 3 square ... 10 of the square lamp, namely the number is 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 of the lamp, this 10 light is bright.

Turn off the lights on the lights

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.