Posts

Showing posts with the label number-theory

how to solve ALICESIE on spoj. How it has common pattern for its answer

how to solve ALICESIE on spoj. How it has common pattern for its answer What is the logic behind pattern i.e.(ans=(n+1)/2) in question ALICESIE on spoj. Algorithm_given: 1.Create a list of consecutive integers from N to 2 (N, N-1, N-2, ..., 3, 2). All of those N-1numbers are initially unmarked. 2.Initially, let P equal N, and leave this number unmarked. 3.Mark all the proper divisors of P (i.e. P remains unmarked). 4.Find the largest unmarked number from 2 to P – 1, and now let P equal this number. 5.If there were no more unmarked numbers in the list, stop. Otherwise, repeat from step 3. Find total number of unmarked numbers. i know its O(sqrt(n)) solution but answer is expected in O(1),it can found by seeing the common pattern i.e.(N+1)/2 But how to prove it Mathematically link: ALICESIE I'm voting to close this question as off-topic because it is a "link-only" question; its meaning depends on a document elsewhere, which could change or vani...