목록전체 글 (317)
지나가던 개발자
n = int(input()) people = [] for i in range(n): people.append(list(map(int, input().split()))) for i in people: ranking = 1 for j in people: if i[0] < j[0] and i[1] < j[1]: ranking += 1 print(ranking, end=" ")
import sys for i in range(int(sys.stdin.readline())): n = int(sys.stdin.readline()) if n == 0: print("Case #"+str(i+1)+": INSOMNIA") continue j = 1 s = [] while True: for k in set(str(n*j)): if int(k) not in s: s.append(int(k)) if 0 in s and 1 in s and 2 in s and 3 in s and 4 in s and 5 in s and 6 in s and 7 in s and 8 in s and 9 in s: print("Case #"+str(i+1)+": "+str(n*j)) break j += 1
import math def is_prime(n): if n == 1: return False for i in range(2, int(math.sqrt(n))+1): if n % i == 0: return False return True n = int(input()) i = 2 ans = [] while True: if is_prime(i): ans.append(i) if len(ans) == 2: if ans[0]*ans[1] > n: print(ans[0]*ans[1]) break del ans[0] if i == 2: i += 1 continue i += 2
import math n = int(input()) A = list(map(int, input().split())) x = int(input()) sumDivide = [0, 0] for i in A: if math.gcd(i, x) == 1: sumDivide[0] += i sumDivide[1] += 1 print(sumDivide[0]/sumDivide[1])
[print(" ".join(list(map(str, x)))) for x in sorted([list(map(int, input().split())) for y in range(int(input()))])] 이왜진?이다... ㅋㅋㅋㅋ sorted()만으로 된다는 점에 놀랐다. 숏코딩 5등...! 이런 영예로운 기회를 얻다니...
from itertools import combinations import math for i in range(int(input())): m = list(map(int, input().split())) biggest = 0 for j in combinations(m, 2): if math.gcd(j[0], j[1]) > biggest: biggest = math.gcd(j[0], j[1]) print(biggest)
#include int main() { int n; int a = 1; scanf("%d", &n); for (int i=2; i*i
import math a, b = map(int, input().split()) print(math.lcm(a, b))
input() [print(x, end=" ") for x in sorted(list(map(int, input().split())))] 숏코딩 81위...!
import sys n, s = map(int,sys.stdin.readline().split()) cows = [int(sys.stdin.readline()) for x in range(n)] ans = 0 while True: try: i = cows[0] del cows[0] except: break for j in cows: if i + j
while True: n = int(input()) if n == 0: break studentsAndHeights = [input().split() for i in range(n)] print(" ".join([x[0] for x in studentsAndHeights if float(x[1])==max([float(y[1]) for y in studentsAndHeights])])) 숏코딩을 하고 싶어서 일부러 이렇게 난해한 코드를 짰는데... 무려 14등..>! 기쁘다.
n, d = input().split() frequency = 0 for i in range(1, int(n)+1): frequency += str(i).count(d) print(frequency) 오늘 과학고 2차면접을 봤는데... 하... 우울하다. 시간이 너무 부족하고 시간배분 잘 못해서 대답 끝까지 못하고 끊긴 것들도 있었고, 문제 다 풀려고 뇌피셜로 푼 문제도 몇 있었다. 그냥 일반고 가야하나..
import math print(math.isqrt(int(input()))) 원래 이분 탐색을 사용하는 문제인데 이렇게 해도 풀린다... ㄷ
games = {"Y": 1, "F": 2, "O": 3} n, game = input().split() nicknames = [] for i in range(int(n)): nicknames.append(input()) print(len(set(nicknames)) // games[game]) 별 생각 안하고 임스가 한 번 플레이한 사람하고는 플레이하지 않으니까 그냥 몫을 구하면 되겠다 하고 했는데 이게 왜 맞지..?
from datetime import datetime youngest = ["", datetime.strptime("1990 01 01", "%Y %m %d")] oldest = ["", datetime.strptime("2010 12 31", "%Y %m %d")] for i in range(int(input())): nameAndBirth = input() name = nameAndBirth.split()[0] birth = datetime.strptime(" ".join(nameAndBirth.split()[1:]), "%d %m %Y") if birth = youngest[1]: youngest[0] = name youngest[1] = birth print(youngest[0]) print(ol..
while True: pw = input() if pw == "end": break if "a" not in pw and "i" not in pw and "u" not in pw and "e" not in pw and "o" not in pw: print(" is not acceptable.") continue if "aa" in pw or "bb" in pw or "cc" in pw or "dd" in pw or "eee" in pw or "ff" in pw or "gg" in pw or "hh" in pw or "ii" in pw or "jj" in pw or "kk" in pw or "ll" in pw or "mm" in pw or "nn" in pw or "ooo" in pw or "pp" in ..
for i in range(int(input())): print("Case #%d:"%(i+1), " ".join(list(reversed(input().split(" ")))))
from string import ascii_uppercase for i in range(int(input())): tc = [x for x in list(input().upper().replace(" ", "")) if x in list(ascii_uppercase)] if set(tc) == set(ascii_uppercase): triple_pangram = True double_pangram = True pangram = True for j in set(tc): if tc.count(j) >= 3: continue elif tc.count(j) == 2: triple_pangram = False elif tc.count(j) == 1: double_pangram = False if triple_p..
names = [] for i in range(int(input())): names.append(input()) if sorted(names) == names: print("INCREASING") elif sorted(names, reverse=True) == names: print("DECREASING") else: print("NEITHER")
rate = 0 scoreSum = 0 rating = {"A+": 4.5, "A0": 4.0, "B+": 3.5, "B0": 3.0, "C+": 2.5, "C0": 2.0, "D+": 1.5, "D0": 1.0, "F": 0.0} for i in range(20): subject, score, grade = input().split() if grade == "P": continue rate += float(score) * rating[grade] scoreSum += float(score) print(rate/scoreSum)
from string import ascii_uppercase, ascii_lowercase longest = "" while True: s = input().split() if s == []: continue for i in range(len(s)): s[i] = list(s[i]) for j in range(len(s[i])): if s[i][j] in list(ascii_uppercase) or s[i][j] in list(ascii_lowercase) or s[i][j] == "-": continue s[i][j] = "" s[i] = "".join(s[i]) s.sort(key=len, reverse=True) if "E-N-D" in s: if s[0] == "E-N-D": if len(lon..
from string import ascii_uppercase, ascii_lowercase encryption = {" ": 0} for i in range(1, len(list(ascii_uppercase)+list(ascii_lowercase))+1): encryption[(list(ascii_uppercase)+list(ascii_lowercase))[i-1]] = i n = int(input()) numbers = list(map(int, input().split())) plaintext = [] for i in input(): plaintext.append(encryption[i]) if sorted(numbers) == sorted(plaintext): print("y") else: prin..
import math n, m = map(int, input().split(":")) print(str(n//math.gcd(n, m))+":"+str(m//math.gcd(n, m)))
for i in range(int(input())): s = input() l = [] for j in range(0, len(s), int(len(s)**(0.5))): l.append(s[j:j+int(len(s)**0.5)]) for j in range(int(len(s)**(0.5))-1, -1, -1): for k in range(int(len(s)**(0.5))): print(l[k][j], end="") print("") 웃긴게 맨 마지막 줄에 를 입력 안 하면 틀렸습니다가 뜬다..
from string import ascii_lowercase alphabets = list(ascii_lowercase) s = input() dictionary = [] for i in range(int(input())): dictionary.append(input()) printed = False for i in dictionary: if i in s: print(s) printed = True break if not printed: for i in range(1, 26): alpha = {} for j in range(26): a = j+i if a > 25: a -= 26 alpha[alphabets[j]] = alphabets[a] decode = "" for j in s: decode += ..
n = int(input()) A = input().split() p = [0 for x in A] for i in range(n): info = input().split() for j in info: p[A.index(j)] += 1 for i in range(n): A[i] = [A[i], p[i]] A.sort(key=lambda x:x[1], reverse=True) for i in A: print(" ".join(list(map(str, i)))) 이 문제를 풀며 "과연 우리 학교에 나를 이성적으로 좋아하는 애가 있을까?"하는 생각을 잠시 해 보았다. (덕분에 뇌 빼고 코딩해서 코드가 좀 보기 안 좋은 듯 하다) 있다면 올해 졸업하니까 올해 안에 얘기를 해 줬으면 한다. 라지만 있을지 없을지도 ..
s = input() ucpc = "" for i in s: if ucpc == "": if i == "U": ucpc += "U" elif ucpc == "U": if i == "C": ucpc += "C" elif ucpc == "UC": if i == "P": ucpc += "P" elif ucpc == "UCP": if i == "C": ucpc += "C" break if ucpc == "UCPC": print("I love UCPC") else: print("I hate UCPC")