์๋ฐ๋ก๋ง ํ๋ค๊ฐ ํ์ด์ฌ ๊ณต๋ถํ ๊ฒธ ์ด๋ฒ ๋จ๊ณ์์๋ ํ์ด์ฌ์ผ๋ก๋ง ํ์์ต๋๋ค.
1 | 5086 | ๋ฐฐ์์ ์ฝ์ | ์ฑ๊ณต์ถ์ฒ๋ค๊ตญ์ด๋ถ๋ฅ | 7239 | 10516 | 70.288% |
๋ฐฐ์์ ์ฝ์๋ฅผ ๋ฐฐ์ฐ๋ ๋ฌธ์ |
def test(num01, num02) :
if num02 % num01 == 0 :
print("factor")
elif num01 % num02 == 0:
print("multiple")
else :
print("neither")
while True :
number01, number02 = map(int, input().split())
if number02 == 0 and number01==0 :
break
test(number01, number02)
2 | 1037 | ์ฝ์ | ์ฑ๊ณต๋ถ๋ฅ | 12488 | 25527 | 49.747% |
์ฝ์์ ์ฑ์ง์ ํ์ฉํ๋ ๋ฌธ์ |
testNum = int(input())
array = list(map(int,input().split()))
a_max = max(array)
a_min = min(array)
print(a_max * a_min)
3 | 2609 | ์ต๋๊ณต์ฝ์์ ์ต์๊ณต๋ฐฐ์ | ์ฑ๊ณต์ถ์ฒ๋ถ๋ฅ | 23552 | 39661 | 62.096% |
์ต๋๊ณต์ฝ์์ ์ต์๊ณต๋ฐฐ์๋ฅผ ๊ตฌํ๋ ๋ฌธ์ |
def firstTest(a,b) :
if a<b :
temp = a
for i in range(a) :
if b%temp == 0 and a%temp == 0:
break
else :
temp -= 1
else :
temp = b
for i in range(b) :
if b%temp == 0 and a%temp == 0:
break
else :
temp -= 1
return temp
def secondTest(a,b,x) :
print((a//x)*(b//x)*x)
a, b = map(int,input().split())
x=firstTest(a,b)
print(x)
secondTest(a,b,x)
4 | 1934 | ์ต์๊ณต๋ฐฐ์ | ์ฑ๊ณต๋ถ๋ฅ | 15809 | 27243 | 59.910% |
์ ํด๋ฆฌ๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๋ ๋น ๋ฅด๊ฒ ํธ๋ ๋ฌธ์ |
def firstTest(a,b) :
if a<b :
temp = a
for i in range(a) :
if b%temp == 0 and a%temp == 0:
break
else :
temp -= 1
else :
temp = b
for i in range(b) :
if b%temp == 0 and a%temp == 0:
break
else :
temp -= 1
return temp
def secondTest(a,b,x) :
print(a*b//x)
T = int(input())
for i in range(T) :
a, b = map(int,input().split())
secondTest(a,b,firstTest(a,b))
5 | 2981 | ๊ฒ๋ฌธ | ์ฑ๊ณต์ถ์ฒ๋ค๊ตญ์ด๋ถ๋ฅ | 3473 | 18733 | 20.916% |
N๊ฐ์ ์๋ฅผ M์ผ๋ก ๋๋์์ ๋, ๋๋จธ์ง๊ฐ ์ ๋ถ ๊ฐ์ M์ ์ฐพ๋ ๋ฌธ์ |
from math import gcd, sqrt
T = int(input())
array = [input() for i in range(T)]
array= list(map(int, array))
array.sort(reverse=True)
answer = list()
for i in range(1, len(array)) :
x = array[i] - array[i-1]
answer += [(gcd(x))]
for i in range(1,len(answer)):
answer[i] = gcd(answer[i], answer[i-1])
x = int(answer[-1])
a=[]
for i in range(2, int(sqrt(x)) + 1):
if x % i == 0:
a.append(i)
a.append(x // i)
a.append(x)
a = list(set(a))
a.sort()
#a.remove(1)
for i in a:
print(i, end = ' ')
6 | 3036 | ๋ง | ์ฑ๊ณต์ถ์ฒ๋ค๊ตญ์ด๋ถ๋ฅ | 5051 | 6542 | 79.385% |
์ฒซ๋ฒ์งธ ๋ง์ ํ ๋ฐํด ๋๋ ธ์ ๋, ๋๋จธ์ง ๋ง์ด ๋ช ๋ฐํด ๋๋์ง ๊ตฌํ๋ ๋ฌธ์ |
import math
def test(mainNum, subNum) :
x = math.gcd(mainNum, subNum)
print("{0}/{1}".format(mainNum//x, subNum//x))
T = int(input())
array = list(map(int, input().split()))
for i in array :
if i == array[0] : continue
test(array[0], i)
7 | 11050 | ์ดํญ ๊ณ์ 1 | ์ฑ๊ณต๋ถ๋ฅ | 13430 | 20880 | 64.841% |
N๊ฐ์ ๋ฌผ๊ฑด ์ค ์์๋ฅผ ๊ณ ๋ คํ์ง ์๊ณ K๊ฐ๋ฅผ ๊ณ ๋ฅด๋ ๊ฒฝ์ฐ์ ์, ์ดํญ ๊ณ์๋ฅผ ๊ตฌํ๋ ๋ฌธ์ |
def fac1(num) :
if num==1 : return 1
return num*fac(num-1)
def fac2(num) :
temp =1
for i in range(1,num+1) :
temp *= i
return temp
N, K = map(int, input().split())
if K < 0 or K>N :
print(0)
else :
print(fac2(N) // (fac2(K)*fac2(N-K)))
8 | 11051 | ์ดํญ ๊ณ์ 2 | ์ฑ๊ณต๋ถ๋ฅ | 10763 | 28608 | 38.462% |
๋ ๋์ ๋ฒ์์ ์ดํญ ๊ณ์๋ฅผ ๋์ ๊ณํ๋ฒ์ผ๋ก ๊ตฌํ๋ ๋ฌธ์ |
def fac1(num) :
if num==1 : return 1
return num*fac1(num-1)
def fac2(num) :
temp =1
for i in range(1,num+1) :
temp *= i
return temp
N, K = map(int, input().split())
if K < 0 or K>N :
print(0)
else :
print((fac2(N) // (fac2(K)*fac2(N-K)))%10007)
9 | 1010 | ๋ค๋ฆฌ ๋๊ธฐ | ์ฑ๊ณต๋ถ๋ฅ | 15752 | 34705 | 48.470% |
๋ค๋ฆฌ๋ฅผ ๋๋ ๊ฒฝ์ฐ์ ์๋ฅผ ๊ตฌํ๋ ๋ฌธ์ |
def fac(num) :
temp =1
for i in range(1,num+1) :
temp *= i
return temp
def fac1(num) :
if num==1 : return 1
return num*fac1(num-1)
T = int(input())
for i in range(T) :
b, a = map(int, input().split())
x= fac(a-b)*fac(b)
y = fac(a)
print(y//x)
10 | 9375 | ํจ์ ์ ์ ํด๋น | ์ฑ๊ณต์ถ์ฒ๋ค๊ตญ์ด๋ถ๋ฅ | 4745 | 8973 | 54.356% |
๊ฒฝ์ฐ์ ์ ์ฐ์ต๋ฌธ์ |
from collections import Counter
t = int(input())
for i in range(t):
n = int(input())
s = []
for j in range(n):
a, b = input().split()
s.append(b)
num = 1
result = Counter(s)
for key in result:
num *= result[key] + 1
print(num - 1)
##์ฒ์์ ์๋๊ฐ์ด ์ ๊ทผํ๋ค๊ฐ collections ์๊ฐ๋์ ๋ค์ํ์์
# import math
# T = int(input())
# array = []
# for i in range(T) :
# x = int(input())
# for j in range(x) :
# array[i].append(input().split())
# array[i].sort(key = lambda x: (x[1]))
# tempStr = array[i][0][1]
# count = 1
# subSum = 0
# for z in range(len(array[0])) :
# if z == 0 : continue
# if array[i][z][1] == tempStr :
# if z == len(array[0])-1 and count !=1 :
# subSum += math.factorial(count)
# break
# else :
# count +=1
# continue
# elif count == 1 :
# tempStr = array[i][z][1]
# continue
# else :
# subSum += math.factorial(count)
# count = 1
# tempStr = array[i][z][1]
# continue
# max = math.factorial(len(array[0]))
# print(max - subSum +1)
# ##############################
# # def x :
# # for a,b in array[0] :
# # if firstPass == 0 :
# # firstPass +=1
# # continue
# # if b == tempStr :
# # count += 1
# # firstPass +=1
# # continue
# # elif count == 1 :
# # firstPass +=1
# # continue
# # else :
# # subSum += math.factorial(count)
# # firstPass +=1
# # count = 1
# # continue
# # if firstPass == len(array[i])-1:
# # subSum += math.factorial(count)
# # break
11 | 1676 | ํฉํ ๋ฆฌ์ผ 0์ ๊ฐ์ | ์ฑ๊ณต๋ถ๋ฅ | 11789 | 24977 | 47.672% |
์์ธ์๋ถํด์ ์ฑ์ง์ ํ์ฉํ์ฌ N!์ ๋์ 0์ด ์ผ๋ง๋ ๋ง์ด ์ค๋์ง ๊ตฌํ๋ ๋ฌธ์ |
x = int(input())
print(x//5 + x//25 + x//125)
12 | 2004 | ์กฐํฉ 0์ ๊ฐ์ | ์ฑ๊ณต๋ถ๋ฅ | 6233 | 22764 | 28.769% |
์์ ๋น์ทํ๋ฐ N! ๋์ ์ดํญ๊ณ์๊ฐ ๋ค์ด๊ฐ ๋ฌธ์ |
import math
def zero(num, x) :
temp = x
sum = 0
while temp<=2000000000 :
sum += num//temp
temp *= x
return sum
N, K = map(int, input().split())
if K < 0 or K>N :
print(0)
else :
a = zero(N,5) - zero(K,5) - zero(N-K,5)
b = zero(N,2) - zero(K,2) - zero(N-K,2)
print(min(a,b))
์ด๋ฒ ๋จ๊ณ๋ ์ข ์ฝ๋ค๊ณ ๋๊ปด์ ธ์ ํธํ๊ฒ Github ์๋ ์ฑ์ธ ๊ฒธ ํ์ด์ฌ์ผ๋ก ํ์๋ค.
728x90
๋ฐ์ํ