Showing posts with label SGU. Show all posts
Showing posts with label SGU. Show all posts

Monday, November 28, 2011

SGU 116. Index of super-prime Solution

time limit per test: 0.5 sec. 
memory limit per test: 4096 KB
Let P1, P2, … ,PN, … be a sequence of prime numbers. Super-prime number is such a prime number that its current number in prime numbers sequence is a prime number too. For example, 3 is a super-prime number, but 7 is not. Index of super-prime for number is 0 iff it is impossible to present it as a sum of few (maybe one) super-prime numbers, and if such presentation exists, index is equal to minimal number of items in such presentation. Your task is to find index of super-prime for given numbers and find optimal presentation as a sum of super-primes.

Thursday, November 3, 2011

SGU Problem 105. Div 3 Solution




Problem Description :
    There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3.