solution to that "difficult question"
"最后一道题目非常难,题目的意思是,24=2*12=3*8=4*6=2*2*6=...
{2, 12}是24的一个set,{3,8}也是24的一个set,{2,12}和{12, 2}算同一个set,{24}也是{24}的一个set。24有7个这样的set。要你算出若干数的set的个数,并且把最大的那个数以及它的set数找出来。"
really?
Here is a possible way:
Firstly, use recursion to get the factoriazation of the number, say 24 = 2^3*3
N=p1^e1*p2^e2*p3^e3...*(pn^en)
p1^e1 means p1 tp the power of e1.
Then, use this formula:
number of different set=(e1+1)*(e2+1)*...(en+1)-1, here minus 1 is to remove {1, N} and {N, 1} duplication.
So surprise, a TA says such question is "very difficult". Do you think you are disappointing the students?
Shamed, shamed, shamed......
:D Kidding.
{2, 12}是24的一个set,{3,8}也是24的一个set,{2,12}和{12, 2}算同一个set,{24}也是{24}的一个set。24有7个这样的set。要你算出若干数的set的个数,并且把最大的那个数以及它的set数找出来。"
really?
Here is a possible way:
Firstly, use recursion to get the factoriazation of the number, say 24 = 2^3*3
N=p1^e1*p2^e2*p3^e3...*(pn^en)
p1^e1 means p1 tp the power of e1.
Then, use this formula:
number of different set=(e1+1)*(e2+1)*...(en+1)-1, here minus 1 is to remove {1, N} and {N, 1} duplication.
So surprise, a TA says such question is "very difficult". Do you think you are disappointing the students?
Shamed, shamed, shamed......
:D Kidding.