21.02.11[247 Algorithm 4회차]

boj_2960

import sys

N, K = map(int, sys.stdin.readline().split())
p_num = [0 for i in range(N+1)]
p_num[0] = 1
p_num[1] = 1

cnt = 0

for i in range(2, N+1):
    if p_num[i] == 0:
        for j in range(i, N+1, i):
            if p_num[j]==0:
                p_num[j]=1
                cnt+=1
                if cnt == K:
                    print(j)

    else:
        continue

boj_3036

import sys

def gcd(a, b):
    while b!=0:
        a,b = b, a%b
    return aac


N = int(sys.stdin.readline())
r_list = list(map(int, sys.stdin.readline().split()))
r2_list = r_list[1:N]
first_ring= r_list[0]

for i in range(len(r2_list)):
    tmp = r2_list[i]
    gcd_val = gcd(tmp,first_ring)
    ans = str(first_ring// gcd_val) + '/' +  str(tmp//gcd_val)
    print(ans)

좋은 웹페이지 즐겨찾기