Saturday, May 25, 2013

1. Life, the Universe, and Everything

http://www.spoj.com/problems/TEST/

CODE

while(True):
    n=int(input())
    if(n==42):
        break
    else:
        print(n)

Thursday, May 23, 2013

6297. Decipher

http://www.spoj.com/problems/ROOTCIPH/

Code

 t=int(input())
for i in range(t):
    s=raw_input()
    str=s.split(' ')
    a=int(str[0])
    b=int(str[1])
    c=int(str[2])
    print(a*a-2*b)


9935. Break the Chocolate

http://www.spoj.com/problems/BC/


from math import log, ceil
ct = input()
i = 1
while ct:
    ct -= 1
    a, b, c = map(int, raw_input().split())
    t = a * b * c
    x = ceil(log(a, 2)) + ceil(log(b, 2)) + ceil(log(c, 2))
    print "Case #%d: %d %d" % (i, t - 1, int(x))
    i += 1

11931. AMZ Word

http://www.spoj.com/problems/AMZSEQ/
lst = [0] * 25
lst[0] = 1
lst[1] = 3
for i in range(2, 25):
    lst[i] = 2 * lst[i - 1] + lst[i - 2]
n = input()
print lst[n]