Skip to content

Commit b38e5d0

Browse files
authored
19/05/2019
1 parent b587540 commit b38e5d0

20 files changed

+373
-0
lines changed

1435.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def setNumbers(m):
2+
s = 0
3+
for i in range(int(round(len(m)/2)) + 1):
4+
rn = len(m[0]) - s
5+
for i2 in range(rn - s):
6+
m[s][i2 + s] = s + 1
7+
8+
for i2 in range(rn - s):
9+
m[rn - 1][i2 + s] = s + 1
10+
11+
for i2 in range(rn - s):
12+
m[s + i2][s] = s + 1
13+
14+
for i2 in range(rn - s):
15+
m[s + i2][rn - 1] = s + 1
16+
17+
s += 1
18+
19+
return m
20+
21+
def printMatriz(m):
22+
for e in m:
23+
t = ""
24+
for e2 in e:
25+
if e2 >= 10:
26+
t += " " + str(e2) + " "
27+
else:
28+
t += " " + str(e2) + " "
29+
print t[0:len(t) - 1]
30+
print ""
31+
32+
while True:
33+
x = input()
34+
m = []
35+
36+
if x == 0:
37+
break
38+
39+
for i in range(x):
40+
l = []
41+
for i2 in range(x):
42+
l.insert(len(l), 0)
43+
m.insert(len(m), l)
44+
45+
m = setNumbers(m)
46+
printMatriz(m)

1828.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
x = input()
2+
for i in range(x):
3+
a, b = (raw_input()).split(' ')
4+
c = i + 1
5+
6+
if a == b:
7+
print "Caso #" + str(c) + ": De novo!"
8+
elif a == "tesoura" and b == "papel":
9+
print "Caso #" + str(c) + ": Bazinga!"
10+
elif b == "tesoura" and a == "papel":
11+
print "Caso #" + str(c) + ": Raj trapaceou!"
12+
elif a == "papel" and b == "pedra":
13+
print "Caso #" + str(c) + ": Bazinga!"
14+
elif b == "papel" and a == "pedra":
15+
print "Caso #" + str(c) + ": Raj trapaceou!"
16+
elif a == "pedra" and b == "lagarto":
17+
print "Caso #" + str(c) + ": Bazinga!"
18+
elif b == "pedra" and a == "lagarto":
19+
print "Caso #" + str(c) + ": Raj trapaceou!"
20+
elif a == "lagarto" and b == "Spock":
21+
print "Caso #" + str(c) + ": Bazinga!"
22+
elif b == "lagarto" and a == "Spock":
23+
print "Caso #" + str(c) + ": Raj trapaceou!"
24+
elif a == "Spock" and b == "tesoura":
25+
print "Caso #" + str(c) + ": Bazinga!"
26+
elif b == "Spock" and a == "tesoura":
27+
print "Caso #" + str(c) + ": Raj trapaceou!"
28+
elif a == "tesoura" and b == "lagarto":
29+
print "Caso #" + str(c) + ": Bazinga!"
30+
elif b == "tesoura" and a == "lagarto":
31+
print "Caso #" + str(c) + ": Raj trapaceou!"
32+
elif a == "lagarto" and b == "papel":
33+
print "Caso #" + str(c) + ": Bazinga!"
34+
elif b == "lagarto" and a == "papel":
35+
print "Caso #" + str(c) + ": Raj trapaceou!"
36+
elif a == "papel" and b == "Spock":
37+
print "Caso #" + str(c) + ": Bazinga!"
38+
elif b == "papel" and a == "Spock":
39+
print "Caso #" + str(c) + ": Raj trapaceou!"
40+
elif a == "Spock" and b == "pedra":
41+
print "Caso #" + str(c) + ": Bazinga!"
42+
elif b == "Spock" and a == "pedra":
43+
print "Caso #" + str(c) + ": Raj trapaceou!"
44+
elif a == "pedra" and b == "tesoura":
45+
print "Caso #" + str(c) + ": Bazinga!"
46+
elif b == "pedra" and a == "tesoura":
47+
print "Caso #" + str(c) + ": Raj trapaceou!"
48+

1847.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
x, y, z = raw_input().split(' ')
2+
x = int(x)
3+
y = int(y)
4+
z = int(z)
5+
6+
if x > y and z >= y:
7+
print ':)'
8+
elif y > x and y >= z:
9+
print ':('
10+
elif y > x and z > y and (z - y) < (y - x):
11+
print ':('
12+
elif y > x and z > y and (z - y) >= (y - x):
13+
print ':)'
14+
elif x > y and y > z and (y - z) < (x - y):
15+
print ':)'
16+
elif y > x and y > z and (y - z) >= (y - z):
17+
print ':('
18+
elif x == y and z > y:
19+
print ':)'
20+
else:
21+
print ':('

1848.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
s = 0
2+
n = 0
3+
while n != 3:
4+
x = raw_input()
5+
6+
if x == "caw caw":
7+
print s
8+
s = 0
9+
n += 1
10+
else:
11+
s += int(x.replace('-', '0').replace('*', '1'), 2)

1959.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x, y = raw_input().split(' ')
2+
x = int(x)
3+
y = int(y)
4+
5+
print x * y

1984.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x = input()
2+
print str(x)[::-1].replace('L', '')

2031.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
x = input()
2+
for i in range(x):
3+
y = raw_input()
4+
z = raw_input()
5+
6+
if y == "ataque" and z == "pedra":
7+
print "Jogador 1 venceu"
8+
elif z == "ataque" and y == "pedra":
9+
print "Jogador 2 venceu"
10+
elif y == "pedra" and z == "papel":
11+
print "Jogador 1 venceu"
12+
elif z == "pedra" and y == "papel":
13+
print "Jogador 2 venceu"
14+
elif y == "ataque" and z == "papel":
15+
print "Jogador 1 venceu"
16+
elif z == "ataque" and y == "papel":
17+
print "Jogador 2 venceu"
18+
elif y == "papel" and z == "papel":
19+
print "Ambos venceram"
20+
elif y == "pedra" and z == "pedra":
21+
print "Sem ganhador"
22+
elif y == "ataque" and z == "ataque":
23+
print "Aniquilacao mutua"

2126.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
c = 1
2+
3+
while True:
4+
try:
5+
x = raw_input()
6+
y = raw_input()
7+
n = len(y.split(x)) - 1
8+
9+
print "Caso #" + str(c) + ":"
10+
11+
if n != 0:
12+
print "Qtd.Subsequencias: " + str(n)
13+
print "Pos: " + str(y.rindex(x) + 1)
14+
else:
15+
print "Nao existe subsequencia"
16+
print ""
17+
c += 1
18+
except EOFError:
19+
break

2139.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
m = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31,30, 31]
2+
3+
while True:
4+
try:
5+
x, y = raw_input().split(' ')
6+
x = int(x)
7+
y = int(y)
8+
s = 0
9+
10+
for i in range(x - 1):
11+
s += m[i]
12+
13+
s += y
14+
15+
if s == 359:
16+
print "E vespera de natal!"
17+
elif s == 360:
18+
print "E natal!"
19+
elif s < 360:
20+
print "Faltam " + str(360 - s) + " dias para o natal!"
21+
elif s > 360:
22+
print "Ja passou!"
23+
except EOFError:
24+
break

2167.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
x = input()
2+
y = raw_input().split(' ')
3+
l = int(y[0])
4+
q = 0
5+
6+
for i in range(x - 1):
7+
i += 1
8+
if l > int(y[i]):
9+
q = i + 1
10+
break
11+
12+
l = int(y[i])
13+
14+
print q

2172.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
while True:
2+
x, y = raw_input().split(' ')
3+
x = int(x)
4+
y = int(y)
5+
6+
if x == 0 and y == 0:
7+
break
8+
9+
print y * x

2234.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x, y = raw_input().split(' ')
2+
x = float(x)
3+
y = float(y)
4+
5+
print '{:.2f}'.format(x/y)

2483.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
x = input()
2+
t = "Feliz nat"
3+
4+
for i in range(x):
5+
t += "a"
6+
7+
print t + "l!"

2523.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
while True:
2+
try:
3+
x = raw_input()
4+
y = input()
5+
z = raw_input().split(' ')
6+
t = ""
7+
8+
for e in z:
9+
t += x[int(e) - 1]
10+
11+
print t
12+
except EOFError:
13+
break

2540.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
while True:
2+
try:
3+
x = input()
4+
y = raw_input().split(' ')
5+
p = 0
6+
7+
for e in y:
8+
if e == "1":
9+
p += 1
10+
11+
if p >= 2/3.0 * x:
12+
print "impeachment"
13+
else:
14+
print "acusacao arquivada"
15+
except EOFError:
16+
break

2543.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
while True:
2+
try:
3+
x, y = raw_input().split(' ')
4+
x = int(x)
5+
g = 0
6+
7+
for i in range(x):
8+
z = raw_input().split(' ')
9+
if z[0] == y and z[1] == "0":
10+
g += 1
11+
12+
print g
13+
except EOFError:
14+
break

2547.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import math
2+
3+
while True:
4+
try:
5+
a, b, c = raw_input().split(' ')
6+
a = int(a)
7+
b = int(b)
8+
c = int(c)
9+
d = 0
10+
11+
for i in range(a):
12+
x = input()
13+
if x >= b and x <= c:
14+
d += 1
15+
16+
print d
17+
except EOFError:
18+
break

2581.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x = input()
2+
3+
for i in range(x):
4+
a = raw_input()
5+
print "I am Toorg!"

2582.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
x = input()
2+
l = ["PROXYCITY", "P.Y.N.G.", "DNSUEY!", "SERVERS",
3+
"HOST!", "CRIPTONIZE", "OFFLINE DAY", "SALT",
4+
"ANSWER!", "RAR?", "WIFI ANTENNAS"]
5+
6+
for i in range(x):
7+
y = (raw_input()).split(' ')
8+
a = int(y[0])
9+
b = int(y[1])
10+
print(l[a + b])

2865.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
def binary(n):
2+
b = bin(n)
3+
b = b[2:len(b)]
4+
return b
5+
6+
def invert(b):
7+
return b[::-1]
8+
9+
def best(bestn, bestt, y, t):
10+
for i in range(bestn):
11+
i+=1
12+
13+
if t == '+ ':
14+
nb = binary(y + i)
15+
16+
if t == '- ':
17+
nb = binary(y - i)
18+
19+
if t == 'x ':
20+
nb = binary(y * i)
21+
22+
if t == '/ ':
23+
nb = binary(y / i)
24+
25+
ninv = invert(nb)
26+
27+
if nb == ninv:
28+
if(bestn > i):
29+
bestn = i
30+
bestt = t
31+
break
32+
return [bestn, bestt]
33+
34+
x = input()
35+
36+
for i in range(x):
37+
y = input()
38+
b = binary(y)
39+
inv = invert(b)
40+
bestt = ""
41+
bestn = 100
42+
43+
if inv == b:
44+
print('*')
45+
continue
46+
47+
for i in range(50):
48+
i+=1
49+
nb = binary(y + i)
50+
ninv = invert(nb)
51+
52+
if nb == ninv:
53+
if(bestn > i):
54+
bestn = i
55+
bestt = '+ '
56+
break
57+
58+
bestn, bestt = best(bestn, bestt, y, '+ ')
59+
bestn, bestt = best(bestn, bestt, y, '- ')
60+
bestn, bestt = best(bestn, bestt, y, 'x ')
61+
bestn, bestt = best(bestn, bestt, y, '/ ')
62+
63+
print(bestt + str(bestn))

0 commit comments

Comments
 (0)