complete 1010.py 2004.py 9375.py
This commit is contained in:
20
zeta_python/completed/1010.py
Normal file
20
zeta_python/completed/1010.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
def case(N, M):
|
||||||
|
"""
|
||||||
|
정의역의 원소가 N개이고 치역의 공역의 원소가 M개인 일대일 '증가' 함수의 경우의 수
|
||||||
|
(M)C(N)
|
||||||
|
"""
|
||||||
|
ans = 1
|
||||||
|
for i in range(M - N + 1, M + 1):
|
||||||
|
ans *= i
|
||||||
|
for i in range(1, N + 1):
|
||||||
|
ans //= i
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
def solve(T, I):
|
||||||
|
return "\n".join([str(case(*I[i])) for i in range(T)])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
T = int(input())
|
||||||
|
print(solve(T, [list(map(int, input().split())) for _ in range(T)]))
|
||||||
28
zeta_python/completed/2004.py
Normal file
28
zeta_python/completed/2004.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
def get_2_5(_to):
|
||||||
|
c2, c5 = 0, 0
|
||||||
|
|
||||||
|
k = 1
|
||||||
|
while k <= _to:
|
||||||
|
k *= 2
|
||||||
|
c2 += _to // k
|
||||||
|
k = 1
|
||||||
|
while k <= _to:
|
||||||
|
k *= 5
|
||||||
|
c5 += _to // k
|
||||||
|
|
||||||
|
return c2, c5
|
||||||
|
|
||||||
|
|
||||||
|
def solve(N, M):
|
||||||
|
count_2, count_5 = get_2_5(N)
|
||||||
|
t = get_2_5(N - M)
|
||||||
|
count_2 -= t[0]
|
||||||
|
count_5 -= t[1]
|
||||||
|
t = get_2_5(M)
|
||||||
|
count_2 -= t[0]
|
||||||
|
count_5 -= t[1]
|
||||||
|
return min((count_2, count_5))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(solve(*map(int, input().split())))
|
||||||
29
zeta_python/completed/9375.py
Normal file
29
zeta_python/completed/9375.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
def case(N, cloth):
|
||||||
|
cloth_dict = {}
|
||||||
|
for i in range(N):
|
||||||
|
if cloth[i][1] in cloth_dict:
|
||||||
|
cloth_dict[cloth[i][1]] += 1
|
||||||
|
else:
|
||||||
|
cloth_dict[cloth[i][1]] = 1
|
||||||
|
ret = 1
|
||||||
|
for i in cloth_dict.values():
|
||||||
|
ret *= i + 1
|
||||||
|
return ret - 1
|
||||||
|
|
||||||
|
|
||||||
|
def solve(T, I):
|
||||||
|
return "\n".join([str(case(I[i][0], I[i][1])) for i in range(T)])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
T = int(input())
|
||||||
|
I = []
|
||||||
|
for _ in range(T):
|
||||||
|
N = int(input())
|
||||||
|
temp = []
|
||||||
|
for _ in range(N):
|
||||||
|
gs = input().split()
|
||||||
|
temp.append(gs)
|
||||||
|
I.append((N, temp))
|
||||||
|
|
||||||
|
print(solve(T, I))
|
||||||
Reference in New Issue
Block a user