목록Python Algorithm (133)
cool hamsters never sleep
dish = list(input()) h = 10 for i in range (len(dish)-1) : if dish[i] == dish[i+1] : h = h + 5 else : h = h + 10 print(h)
n = int(input()) s = list(map(int, input().split())) sum = 0 finalsum = 0 for i in range (n) : if s[0+i] == 1 : sum += 1 finalsum += sum else : sum = 0 print(finalsum)
a, b, c = 300, 60, 10 an, bn, cn = 0, 0, 0 t = int(input()) if t= 300 : an = t//300 t = t - (an*300) bn = t//60 t = t - (bn*60) cn = t//10 else : bn = t//60 t = t - (bn*60) cn = t//10 print(an, bn, cn) 100점 받은 코드입니다~
g, b = 0, 0 y = [] z = [] for i in range (int(input())) : x = list(input()) g = x.count("G") + x.count("g") b = x.count("B") + x.count("b") s = "".join(x) y.append(s) if g > b : z.append("is GOOD") elif g < b : z.append("is A BADDY") else : z.append("is NEUTRAL") g, b = 0, 0 for i in range (len(y)) : print(y[i], z[i])
a, b, c = map(int, input().split()) d = int(input()) x = d//3600 y = (d-(x*3600))//60 z = d%60 h = a+x m = b+y s = c+z if s >= 60 : m = m+(s//60) s = s-60 if m >= 60 : h = h+(m//60) m = m-60 if h >= 24 : h = h%24 print(h, m, s) 고전했습니다만 머리가 꽤나 똑똑해진 느낌이군요
for i in range (int(input())) : a = list(input().split()) a1 = float(a[0]) for j in range (len(a)) : if a[0+j] == '@' : a1 = a1*3 if a[0+j] == '%' : a1 = a1+5 if a[0+j] == '#' : a1 = a1-7 print("{0:0.2f}".format(a1)) @는 3을 곱하고, %는 5를 더하며, #는 7을 빼는 연산자입니다. 어떤 연산자가 앞에 있으냐에 따라서 값이 달라진다는 것을 생각하고... 소수점 둘째짜리까지 표시하기 위해 format 함수를 사용했습니다.