Monday, November 21, 2011

TC SRM 524

p250
notice that if n is prime, then do it 2 times, one with n-1 and one with 1. if n is not prime, then do it only 1 time. There are two special cases, when n is 1, do it only 1 time, and when n is 3, need three times. The reason is that any prime above 3 has n-1 being nonprime while 3-1=2 is prime.

p500: unsolved
if all c[i]>0 or all c[i]<0, then answer is infinity. some upper bound, length <= lcm(c+, c-) since the smallest abs c[i]>0 and c[i]<0, their lcm will be both >0 and <0, which is impossible.
some lower bound is min(abs(c[i]))-1, then no restrictions apply and the sequence is always good.

p1000:

No comments:

Post a Comment