Skip to content

Commit 5117d30

Browse files
author
IsHYuhi
committed
ARC104-ARC106
1 parent 0089e70 commit 5117d30

File tree

6 files changed

+98
-0
lines changed

6 files changed

+98
-0
lines changed

Diff for: ARC/ARC104/A.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a, b = map(int, input().split())
2+
3+
for i in range(-100, 101):
4+
for j in range(-100, 101):
5+
if i+j == a and i-j == b:
6+
print(i, j)
7+
exit()

Diff for: ARC/ARC104/B.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#AC with PyPy3
2+
from collections import Counter
3+
n, s = input().split()
4+
n = int(n)
5+
6+
count_org = Counter(s)
7+
count = 0
8+
9+
for i in range(1, n+1)[::-1]:
10+
count_t = count_org.copy()
11+
for j in range(i):
12+
13+
if count_t['A'] == count_t['T'] and count_t['C'] == count_t['G']:
14+
count += 1
15+
16+
count_t[s[j]] -= 1
17+
count_org[s[i-1]] -= 1
18+
19+
print(count)

Diff for: ARC/ARC105/A.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from itertools import combinations
2+
3+
abcd = list(map(int, input().split()))
4+
total = sum(abcd)
5+
6+
for i in range(1, 5):
7+
comb = list(combinations(abcd, i))
8+
9+
for j in comb:
10+
choose = sum([j for j in list(j)])
11+
12+
if choose == total - choose:
13+
print('Yes')
14+
exit()
15+
16+
print('No')
17+

Diff for: ARC/ARC105/B.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from functools import reduce
2+
import math
3+
4+
def my_gcd(numbers):
5+
return reduce(math.gcd, numbers)
6+
7+
n = int(input())
8+
a = list(map(int, input().split()))
9+
print(my_gcd(a))

Diff for: ARC/ARC106/A.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
n = int(input())
2+
3+
for a in range(1, 38):
4+
for b in range(1, 27):
5+
if 3**a + 5**b == n:
6+
print(a, b)
7+
exit()
8+
print(-1)

Diff for: ARC/ARC106/B.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from collections import deque
2+
3+
n, m = map(int, input().split())
4+
a = list(map(int, input().split()))
5+
b = list(map(int, input().split()))
6+
visited = [False]*n
7+
graph = [[] for i in range(n)]
8+
9+
for i in range(m):
10+
c, d = map(int, input().split())
11+
graph[c-1].append(d-1)
12+
graph[d-1].append(c-1)
13+
14+
def bfs(start):
15+
q = deque([start])
16+
visited[start] = True
17+
ans = []
18+
while q:
19+
now = q.popleft()
20+
ans.append(now)
21+
for i in graph[now]:
22+
if visited[i] == False:
23+
visited[i] = True
24+
q.append(i)
25+
26+
return ans
27+
28+
for v in range(n):
29+
30+
if visited[v] == False:
31+
nodes = bfs(v)
32+
33+
if sum(a[idx] for idx in nodes) != sum(b[idx] for idx in nodes):
34+
print('No')
35+
exit()
36+
37+
print('Yes')
38+

0 commit comments

Comments
 (0)