Wednesday, July 11, 2018

Beautiful Days at the Movies : Algorithms-Implementation

#The solution in Python is as follows:


i,j,k=map(int,input().split())
l=i
beauty=0
while l<=j:
      a=l
      b=str(a)[::-1]
      c=int(b)
      if (c-a)%k==0:
               beauty+=1
      l+=1
print(beauty)

#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!

Sunday, July 8, 2018

EC_CONB - Even Numbers : Classical

#The solution in Python is as follows:


for _ in xrange(int(raw_input())):
        n=int(raw_input())
        if n%2==0:
                a=bin(n)[2:]
                b=a[::-1]
                print int(b,2)
        else:
                print n


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

Thursday, July 5, 2018

SYNC13C - WHAT A CO-ACCIDENT : Classical

#The solution in Python 3 is as follows:


for _ in range(int(input())):
c1,c2=map(int,input().split())
if c1%2 and c2%2:
print('Ramesh')
else:
print('Suresh')


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

Tuesday, July 3, 2018

HANGOVER - Hangover : Classical

#The solution in Python 3 is as follows:


while True:
    c=float(input())
    n=2
    if c==0:
        break
    while c>0:
        c-=1.0/n
        n+=1
    print(n-2,'card(s)')


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

Monday, July 2, 2018

MIRRORED - Mirrored Pairs : Tutorial

#The solution in Python 3 is as follows:


b=[]
while True:
     x=input()
     if x=="  ":
            print("Ready")
            for i in range(len(b)):
                    print(b[i])
            break
    if x=='pq' or x=='qp' or x=='db' or x=='bd':
           b.append("Mirrored pair")
    else:
           b.append("Ordinary pair")


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

GERGOVIA - Wine trading in Gergovia : Classical

#The solution in Python 3 is as follows:


while True:
t=0
w=0
if int(input()) == 0:
               break
for a in list(map(str,input().split())):
t+= int(a)
w+= abs(t)
print(w)


#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!

Sunday, July 1, 2018

VHELSING - Van Helsings gun : Classical

#The solution in Python 3 is as follows:


import math
for _ in range(int(input())):
 r=int(input())
 print('%.4f' % (8*(2-(math.sqrt(2)))*(pow(r,3))))


#Visit this link for detailed information.

#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!