Skip to content

Commit 8ba1295

Browse files
author
IsHYuhi
committed
ABC51-55
1 parent 042970d commit 8ba1295

File tree

16 files changed

+178
-66
lines changed

16 files changed

+178
-66
lines changed

ABC/ABC051/A.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print(input().replace(',', ' '))

ABC/ABC051/B.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from bisect import bisect
2+
k, s = map(int, input().split())
3+
ans = 0
4+
rekkyo = []
5+
for i in range(0,k+1):
6+
for j in range(0,k+1):
7+
if 0<=s-i-j<=k:
8+
ans+=1
9+
print(ans)

ABC/ABC052/A.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a, b, c, d = map(int, input().split())
2+
3+
print(max(a*b,c*d))

ABC/ABC052/B.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
n = int(input())
2+
s = input()
3+
x = 0
4+
ans = 0
5+
for i in s:
6+
if i=='I':
7+
x+=1
8+
elif i=="D":
9+
x-=1
10+
ans = max(ans, x)
11+
print(ans)

ABC/ABC053/A.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if int(input())<1200:
2+
print('ABC')
3+
else:
4+
print('ARC')

ABC/ABC053/B.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
s = input()
2+
for i, st in enumerate(s):
3+
if st=='A':
4+
start = i
5+
break
6+
for i, st in enumerate(s):
7+
if st=='Z':
8+
end = i
9+
print(end-start+1)

ABC/ABC053/C.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import math
2+
x = int(input())
3+
4+
if x<=6:
5+
print(1)
6+
elif x<=11:
7+
print(2)
8+
else:
9+
ans = (x//11)*2
10+
res = (x%11)
11+
if res==0:
12+
res =0
13+
elif res<=6:
14+
res = 1
15+
elif res<=11:
16+
res = 2
17+
print(ans+res)

ABC/ABC054/A.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A, B = map(int, input().split())
2+
if A==B:
3+
print('Draw')
4+
elif A==1:
5+
print('Alice')
6+
elif B==1:
7+
print('Bob')
8+
elif A>B:
9+
print('Alice')
10+
else:
11+
print('Bob')

ABC/ABC054/C.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
N, M = map(int, input().split())
2+
#ab = [list(map(int, input().split())) for i in range(M)]
3+
ab = [[] for _ in range(N)]
4+
5+
for _ in range(M):
6+
a, b = map(int,input().split())
7+
ab[a-1].append(b-1)
8+
ab[b-1].append(a-1)
9+
#print(ab)
10+
11+
count = 0
12+
13+
def dfs(i, now, done):
14+
global count
15+
if i == N-1:
16+
count += 1
17+
#print(now+1)
18+
#print('-----')
19+
return
20+
21+
for j in ab[now]:
22+
#print(j, done)
23+
if j not in done:
24+
#print(j+1)
25+
#done.append(j)
26+
dfs(i+1, j, done + [j])##引数はバラして入れる!
27+
return
28+
29+
dfs(0, 0, [0])
30+
print(count)
31+
32+
# import itertools
33+
34+
# n, m = map(int, input().split())
35+
36+
# path = [[False] * n for i in range(n)]
37+
# for i in range(m):
38+
# a, b = map(int, input().split())
39+
# a -= 1
40+
# b -= 1
41+
# path[a][b] = True
42+
# path[b][a] = True
43+
44+
# ans = 0
45+
46+
# for i in itertools.permutations(range(n), n):#N!
47+
# if i[0] == 0:
48+
# for j in range(n):
49+
# if j == n - 1:
50+
# ans += 1
51+
# break
52+
# if not path[i[j]][i[j + 1]]:
53+
# break
54+
55+
# print(ans)

ABC/ABC055/A.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
A, B = map(int, input().split())
2-
if A==B:
3-
print('Draw')
4-
elif A==1:
5-
print('Alice')
6-
elif B==1:
7-
print('Bob')
8-
elif A>B:
9-
print('Alice')
10-
else:
11-
print('Bob')
1+
n = int(input())
2+
print(n*800-(n//15)*200)

ABC/ABC055/B.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#PyPy3
2+
n = int(input())
3+
ans = 1
4+
for i in range(1,n+1):
5+
ans = (ans*i)%1000000007
6+
print(ans)

ABC/ABC055/C.py

+6-55
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
1-
N, M = map(int, input().split())
2-
#ab = [list(map(int, input().split())) for i in range(M)]
3-
ab = [[] for _ in range(N)]
4-
5-
for _ in range(M):
6-
a, b = map(int,input().split())
7-
ab[a-1].append(b-1)
8-
ab[b-1].append(a-1)
9-
#print(ab)
10-
11-
count = 0
12-
13-
def dfs(i, now, done):
14-
global count
15-
if i == N-1:
16-
count += 1
17-
#print(now+1)
18-
#print('-----')
19-
return
20-
21-
for j in ab[now]:
22-
#print(j, done)
23-
if j not in done:
24-
#print(j+1)
25-
#done.append(j)
26-
dfs(i+1, j, done + [j])##引数はバラして入れる!
27-
return
28-
29-
dfs(0, 0, [0])
30-
print(count)
31-
32-
# import itertools
33-
34-
# n, m = map(int, input().split())
35-
36-
# path = [[False] * n for i in range(n)]
37-
# for i in range(m):
38-
# a, b = map(int, input().split())
39-
# a -= 1
40-
# b -= 1
41-
# path[a][b] = True
42-
# path[b][a] = True
43-
44-
# ans = 0
45-
46-
# for i in itertools.permutations(range(n), n):#N!
47-
# if i[0] == 0:
48-
# for j in range(n):
49-
# if j == n - 1:
50-
# ans += 1
51-
# break
52-
# if not path[i[j]][i[j + 1]]:
53-
# break
54-
55-
# print(ans)
1+
s, c = map(int, input().split())
2+
ans = 0
3+
ans += min(s,c//2)
4+
res = c-min(s,c//2)*2
5+
ans += res//4
6+
print(ans)

ABC/ABC173/A.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import math
2+
n = int(input())
3+
4+
print(abs(n-math.ceil(n/1000)*1000))

ABC/ABC173/B.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from collections import Counter
2+
n = int(input())
3+
4+
S = [input() for i in range(n)]
5+
S = Counter(S)
6+
7+
li = ['AC', 'WA', 'TLE', 'RE']
8+
9+
for i in li:
10+
if S.get(i):
11+
print(i+' x '+str(S[i]))
12+
else:
13+
print(i+' x '+str(0))

ABC/ABC173/C.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
h, w, k = map(int,input().split())
2+
3+
field = [list(input()) for i in range(h)]
4+
5+
ans = 0
6+
for maskr in range(0, 1<<h):#1のhビット左シフト2^h
7+
for maskc in range(0, 1<<w):
8+
black = 0
9+
for i in range(h):
10+
for j in range(w):
11+
if ((maskr>>i) & 1) == 0 and ((maskc>>j) & 1) == 0 and field[i][j] == '#':
12+
#mask>>i: maskrのiビット右シフト2^(-i), つまりi番目が1じゃない(赤く塗られていない)かどうかを調べている
13+
#赤く塗られていないかつ、#ならblackとしてカウント, 2^h * 2^w 通り、つまり2^(h+w)通り全探索している
14+
black +=1
15+
if black == k:
16+
ans += 1
17+
print(ans)

ABC/ABC173/D.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from collections import deque
2+
n = int(input())
3+
a = list(map(int, input().split()))
4+
5+
a.sort()
6+
ans = 0
7+
#最大値が1回, それ以降は大きい順に2回ずつ関わる.
8+
for i in range(1, n):
9+
ans += a[n-i//2-1]
10+
print(ans)

0 commit comments

Comments
 (0)