output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s506331653 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | A, B, C = [int(elem) for elem in input().split()]
a = min(A, B + C)
poured = a - B
print(C - poured)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s622503929 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | import copy
S = input()
nN = len(S)
nAns = [1 for i in range(nN)]
nAnsC = [0 for i in range(nN)]
for j in range(10**3):
nAnsT = [0 for i in range(nN)]
for i in range(nN):
sTmp = S[i]
if nAns[i] == 0:
continue
nNum = nAns[i]
nAns[i] = 0
if sTmp == "R":
nTmp = i + 1
elif sTmp == "L":
nTmp = i - 1
nAnsT[nTmp] += nNum
nAns = copy.deepcopy(nAnsT)
if i == 1:
nAnsC = copy.deepcopy(nAnsT)
else:
nTmp2 = i
nTmp2 &= 1
if nTmp2 == 1:
if nAns == nAnsC:
break
else:
nAnsC = copy.deepcopy(nAns)
# print(*nAns)
# sTmp = S[nTmp]
# if sTmp =='R':
# nTmp += 1
# elif sTmp =='L':
# nTmp -= 1
# nAns[nTmp] += 1
print(*nAns)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s692757051 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | def divisors(n) -> list:
res = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
# res = sorted(res)
return res
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s082241694 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | import sys
input = sys.stdin.readline
mod = 998244353
def sub(a, b):
return (a % mod + mod - b % mod) % mod
(n,) = list(map(int, input().split()))
t = 1
dd = [t]
for _ in range(n):
t = 2 * t % mod
dd.append(t)
def power(a, b):
return dd[b]
class SegTree:
def __init__(self, init_val, n, ide_ele, seg_func):
self.segfunc = seg_func
self.num = 2 ** (n - 1).bit_length()
self.ide_ele = ide_ele
self.seg = [self.ide_ele] * 2 * self.num
for i in range(n):
self.seg[i + self.num - 1] = init_val[i]
for i in range(self.num - 2, -1, -1):
self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])
def update(self, k, x):
k += self.num - 1
self.seg[k] = x
while k + 1:
k = (k - 1) // 2
self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
def query(self, p, q):
if q <= p:
return self.ide_ele
p += self.num - 1
q += self.num - 2
res = self.ide_ele
while q - p > 1:
if p & 1 == 0:
res = self.segfunc(res, self.seg[p])
if q & 1 == 1:
res = self.segfunc(res, self.seg[q])
q -= 1
p = p // 2
q = (q - 1) // 2
if p == q:
res = self.segfunc(res, self.seg[p])
else:
res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
return res
def mm(a, b, c, d, n):
return sub(
power(2, b + c) + power(2, c + d) + power(2, d + a) + power(2, a + b),
power(2, a) + power(2, b) + power(2, c) + power(2, d),
)
xs, ys = [], []
for _ in range(n):
x, y = list(map(int, input().split()))
xs.append(x)
ys.append(y)
ini = sorted(list(range(n)), key=lambda x: xs[x])
for i, yi in enumerate(sorted(list(range(n)), key=lambda x: ys[x])):
ys[yi] = i
nys = [ys[i] for i in ini]
ss1 = SegTree([0] * n, n, 0, lambda x, y: x + y)
r = 0
for i, y in enumerate(nys):
ss1.update(y, 1)
d = ss1.query(0, y)
c = i - d
b = (n - 1) - y - c
a = (n - 1) - b - c - d
r = (r + mm(a, b, c, d, n)) % mod
print(sub((power(2, n) * n) % mod, (r + n) % mod))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s324449684 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | s = input()
max_ = 0
pre = s[0]
ren = 1
for i in range(1, len(s)):
if s[i] == pre:
ren += 1
max_ = max(max_, ren)
else:
ren = 1
pre = s[i]
from collections import deque
status = deque([[1] * len(s)])
for i in range(max_):
sta = [0] * len(s)
if s[1] == "L":
sta[0] = status[i][1]
else:
sta[0] = 0
if s[-2] == "R":
sta[-1] = status[i][-2]
else:
sta[-1] = 0
a = [[1] * len(s)]
for j in range(1, len(s) - 1):
# print(sta)
if s[j - 1] == "R":
sta[j] += status[i][j - 1]
if s[j + 1] == "L":
sta[j] += status[i][j + 1]
status.append(sta)
for i in range(1 + max_ - 2):
status.popleft()
if (max_ - 2) % 2 == 0:
print(" ".join([str(i) for i in status[1]]))
else:
print(" ".join([str(i) for i in status[0]]))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s439139408 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | A, B, C = map(int, (input().split()))
print(abs(C - (A - B)))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s790162381 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | print(1)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s150285327 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | while True:
try:
A, B, C = map(int, input().split())
print(max(0, C - (A - B)))
except:
break
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s765771860 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | num = int(input())
re = 0
for i in range(1, num + 1):
if len(str(i)) % 2 != 0:
re += 1
print(re)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s033719050 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | li = list(map(int, input().split()))
print(li[2] - (li[0] - li[1]))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s861938926 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | str = "37"
# str = input()
num = int(str)
const = len(str)
numbers = len(str)
even = 0
con = 0
a = str[even:const]
b = int(a)
if numbers % 2 == 1:
pass
else:
even += 1
numbers -= 1
a = str[even:const]
b = int("9" * (numbers))
while numbers > 0:
con += b - 10 ** (numbers - 1) + 1
even += 2
numbers -= 2
if numbers > 0:
a = str[even:const]
b = int("9" * (numbers))
print(con)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s551387444 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | N = input()
Num = len(N)
if Num == 5:
Ans = (int(N) - 9999) + 900 + 9
elif Num == 4:
Ans = 900 + 9
elif Num == 3:
Ans = (int(N) - 99) + 9
elif Num == 2:
Ans = 9
elif Num == 1:
Ans = N
elif Num == 6:
Ans = 90000 + 900 + 9
print(Ans)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s929118749 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | import sys
a = int(input())
cnt = 0
for i in range(1, 10):
cnt += 1
if i == a:
print(cnt)
sys.exit()
if a < 100:
print(cnt)
sys.exit()
for j in range(100, 1000):
cnt += 1
if j == a:
print(cnt)
sys.exit()
if a < 10000:
print(cnt)
sys.exit()
for k in range(10000, 100000):
cnt += 1
if k == a:
print(cnt)
sys.exit()
if a == 100000:
print(cnt)
sys.exit()
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s845024696 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | N = int(input())
li = list(map(int, input().split()))
li2 = []
key = [0] # key 0でおk 1で1下げ
cnt = 0
flg = True
if N == 1:
ans = "Yes"
flg = False
while flg:
cur1 = li[cnt]
cur2 = li[cnt + 1]
sa = cur2 - cur1
if key[cnt] == 0:
if sa < -1:
ans = "No"
flg = False
elif sa == -1:
key.append(1)
cnt += 1
else:
key.append(0)
cnt += 1
else:
if sa < 0:
ans = "No"
flg = False
else:
key.append(0)
cnt += 1
if cnt == len(li) - 1:
ans = "Yes"
flg = False
print(ans)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s345561294 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | N = input().split(" ")
A = int(N[0])
B = int(N[1])
C = int(N[2])
x = A - B
result = C - x
print(result)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s936699853 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | A, B, C = input().split()
print(max(int(B) + int(C) - int(A), 0))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s604127507 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | i = list(map(int, input().split()))
print(i[2] - (i[0] - i[1]))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s034926269 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | print((lambda x: (x[1] + x[2] - x[0]))(list(map(int, input().split()))))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s241632684 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | def transfer(A, B, C):
return (B + C - A) if (B + C) > A else 0
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s888976836 | Wrong Answer | p02951 | Input is given from Standard Input in the following format:
A B C | lst = list(map(int, input().split()))
print(lst[2] - (lst[0] - lst[1]))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s763086445 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | a, b, c = [int(x) for x in input()]
string = max([c - a - b, 0])
print(string)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s928857143 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | import sys
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
[A, B, C] = string_to_int(inputs[0])
cap = A - B
return C - cap if C - cap >= 0 else 0
def string_to_int(string):
return list(map(lambda x: int(x), string.split()))
if __name__ == "__main__":
ret = solve(inputs(1))
print(ret)
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s143442699 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | IN = input()
A, B, C = [int(x) for x in IN.split(" ")]
total = 0
try:
total = C - min((A - B), C)
print(total)
except:
print("ERROR")
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s404971131 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | N = int(input())
ANS = [0] * 5
flag = 0
if N < 100000:
if N < 10000:
if N < 1000:
if N < 100:
if N < 10:
ANS[0] = int(N / 10)
flag = flag + 1
ANS[1] = 9
flag = flag + 1
ANS[2] = 9 + N - 100 + 1
flag = flag + 1
ANS[3] = 909
flag = flag + 1
ANS[4] = 9 + 900 + N - 10000 + 1
flag = flag + 1
elif N == 100000:
print(90909)
if flag == 5:
print(ANS[0])
if flag == 4:
print(ANS[1])
if flag == 3:
print(ANS[2])
if flag == 2:
print(ANS[3])
if flag == 1:
print(ANS[4])
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s422503023 | Runtime Error | p02951 | Input is given from Standard Input in the following format:
A B C | s = list(input())
def dp(i, j, s):
for ii in range(i):
if s[j] == "R":
j = j + 1
else:
j = j - 1
return j
dic = {}
for x in range(len(s)):
dic[x] = dp(10**3, x, s)
nwli = [0 for q in range(len(s))]
for t in range(len(s)):
nwli[dic[dic[dic[dic[t]]]]] += 1
print(" ".join(map(str, nwli)))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s740755692 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | # 標準入力受け取り
A, B, C = (int(i) for i in input().split())
# 結果表示
print(max(B + C - A, 0))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the integer representing the amount of water, in milliliters, that will
remain in Bottle 2.
* * * | s493785867 | Accepted | p02951 | Input is given from Standard Input in the following format:
A B C | a, b, c = tuple([int(i) for i in input().split(" ")])
print(max([0, c - (a - b)]))
| Statement
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B
milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2? | [{"input": "6 4 3", "output": "1\n \n\nWe will transfer two milliliters of water from Bottle 2 to Bottle 1, and one\nmilliliter of water will remain in Bottle 2.\n\n* * *"}, {"input": "8 3 9", "output": "4\n \n\n* * *"}, {"input": "12 3 7", "output": "0"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s948974905 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | from collections import defaultdict
primes = list(range(2, 101))
for i in range(len(primes)):
if primes[i]:
j = i
j += primes[i]
while j < len(primes):
primes[j] = None
j += primes[i]
primes = [p for p in primes if p]
N = int(input())
fact = defaultdict(int)
for p in primes:
i = p
while i <= N:
fact[p] += N // i
i *= p
f2 = set()
f4 = set()
f14 = set()
f24 = set()
f74 = set()
for p in fact:
if fact[p] >= 2:
f2.add(p)
if fact[p] >= 4:
f4.add(p)
if fact[p] >= 14:
f14.add(p)
if fact[p] >= 24:
f24.add(p)
if fact[p] >= 74:
f74.add(p)
ans = 0
ans += len(f74)
ans += len(f24) * (len(f2) - 1)
ans += len(f14) * (len(f4) - 1)
ans += (len(f2) - 2) * len(f4) * (len(f4) - 1) // 2
print(ans)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s120558705 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
prime_factorization = {}
for i in range(1, N + 1):
d = 2
orig = i
while d < (int(orig**0.5) + 1):
while i % d == 0:
i = i // d
if d in prime_factorization:
prime_factorization[d] += 1
else:
prime_factorization[d] = 1
d += 1
if i > 1:
if i in prime_factorization:
prime_factorization[i] += 1
else:
prime_factorization[i] = 1
greater2 = 0
greater4 = 0
greater14 = 0
greater24 = 0
greater74 = 0
for i in prime_factorization:
if prime_factorization[i] >= 2:
greater2 += 1
if prime_factorization[i] >= 4:
greater4 += 1
if prime_factorization[i] >= 14:
greater14 += 1
if prime_factorization[i] >= 24:
greater24 += 1
if prime_factorization[i] >= 74:
greater74 += 1
combi3 = ((greater4 * (greater4 - 1)) // 2) * (greater2 - 2)
combi2 = (greater14) * (greater4 - 1) + (greater24) * (greater2 - 1)
combi1 = greater74
print(combi1 + combi2 + combi3)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s731196980 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | import numpy as np
def main():
n = int(input())
sosuu = []
sosuucount = []
for i in range(2, n + 1):
num = i
sosuuf = 1
for j in range(len(sosuu)):
if num % sosuu[j] == 0:
sosuuf = 0
while num % sosuu[j] == 0:
num /= sosuu[j]
sosuucount[j] += 1
if sosuuf == 1:
sosuu.append(num)
sosuucount.append(1)
num75 = 0
num25 = 0
num15 = 0
num5 = 0
num3 = 0
for i in range(len(sosuu)):
if sosuucount[i] + 1 >= 75:
num75 += 1
if sosuucount[i] + 1 >= 25:
num25 += 1
if sosuucount[i] + 1 >= 15:
num15 += 1
if sosuucount[i] + 1 >= 5:
num5 += 1
if sosuucount[i] + 1 >= 3:
num3 += 1
r = (
num75
+ num25 * (num3 - 1)
+ num15 * (num5 - 1)
+ num5 * (num5 - 1) * (num3 - 2) / 2
)
print(int(r))
# print(sosuu)
# print(sosuucount)
# print(num3, num5, num15, num25, num75)
main()
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s683802017 | Wrong Answer | p03213 | Input is given from Standard Input in the following format:
N | from math import factorial
from itertools import product
def get_divisors(n):
div = []
append = div.append
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
append(i)
if i != n // i:
append(n // i)
div.sort()
return div
# input
N = int(input())
N_fact = factorial(N)
if N_fact < 357:
print(0)
else:
Nf_dig = len(str(N_fact))
divisors = get_divisors(N_fact)
dig = 3
sgs_nuns = []
sgs = ["7", "5", "3"]
set_sgs = set(sgs)
str_join = "".join
for n in range(3, Nf_dig + 1):
sgs_nuns += [
str_join(n)
for n in product(["7", "5", "3"], repeat=n)
if set(str_join(n)) == set_sgs and int(str_join(n)) in divisors
]
cnt = len(sgs_nuns)
print(cnt)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s508367542 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | def primesbelow(N):
# http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
# """ Input N>=6, Returns a list of primes, 2 <= p < N """
correction = N % 6 > 1
N = {0: N, 1: N - 1, 2: N + 4, 3: N + 3, 4: N + 2, 5: N + 1}[N % 6]
sieve = [True] * (N // 3)
sieve[0] = False
for i in range(int(N**0.5) // 3 + 1):
if sieve[i]:
k = (3 * i + 1) | 1
sieve[k * k // 3 :: 2 * k] = [False] * (
(N // 6 - (k * k) // 6 - 1) // k + 1
)
sieve[(k * k + 4 * k - 2 * k * (i % 2)) // 3 :: 2 * k] = [False] * (
(N // 6 - (k * k + 4 * k - 2 * k * (i % 2)) // 6 - 1) // k + 1
)
return [2, 3] + [(3 * i + 1) | 1 for i in range(1, N // 3 - correction) if sieve[i]]
n = int(input())
primes = primesbelow(n)
factor = {}
def val(n, d):
ans = 0
t = d
while t <= n:
ans += n // t
t *= d
return ans
g2 = 0
g4 = 0
g24 = 0
g14 = 0
g74 = 0
for i in primes:
k = val(n, i)
if k >= 4:
g4 += 1
if k >= 2:
g2 += 1
if k >= 24:
g24 += 1
if k >= 14:
g14 += 1
if k >= 74:
g74 += 1
a = (g2 - 2) * ((g4 * (g4 - 1)) // 2)
b = g24 * (g2 - 1)
c = g14 * (g4 - 1)
d = g74
print(a + b + c + d)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s220183913 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | def slove():
import sys
import collections
input = sys.stdin.readline
n = int(input().rstrip('\n'))
ls = []
for i in range(1, n + 1):
t = i
for j in range(2, int(t ** 0.5) + 1):
while True:
if t % j == 0:
t //= j
ls.append(j)
else:
break
if t > 1:
ls.append(t)
ls = collections.Counter(ls)
ls2 = []
for k, v in ls.items():
if v >= 74:
ls2.append(75)
if v >= 24:
ls2.append(25)
if v >= 14:
ls2.append(15)
if v >= 4:
ls2.append(5)
if v >= 2:
ls2.append(3)
ls2 = collections.Counter(ls2)
cnt = 0s2[3]-1, 0))
cnt += (ls2[15] * max(ls2[5]-1, 0))
cnt += (ls2[5] * max(ls2[5]-1, 0) * max(ls2[3]-2, 0) // 2)
print(cnt)
if __name__ == '__main__':
slove()
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s257698032 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
e = [0] * (N+1)
for i in range(2, N+1):
cur = i
for j in range(2, i+1):
while cur % j == 0:
e[j] += 1
cur //= j
def num(n):
return len(list(filter(lambda x: x >= n-1, e)))
# num(3)-1はnum(25)で3以上のものを一個使っているので、一つ引いている。//2は、例えばa^4 * b^4 * c^2 と b^4 * a^4 * c^2がかぶって計上されるため。
print(num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2) | Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s046286373 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | N = int(input()) e=[0]*(N+1)
for i in range(2, N+1):
cur = i
for j in range(2, i+1):
while cur % j == 0:
e[j] += 1
cur //= j
def num(m):
return len(list(filter(lambda x: x >= m-1, e)))
print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
+ num(5) * (num(5) - 1) * (num(3) - 2) // 2) | Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s598269994 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | from collections import defaultdict, Counter
def primes(x):
d = {}
i = 2
while i <= x:
count = 0
while x % i == 0 and x > 0:
count += 1
x //= i
if count > 0:
d[i] = count
i += 1
return d
if __name__ == "__main__":
n = int(input())
d = {}
for i in range(2, n + 1):
d1 = primes(i)
for j, v in d1.items():
if j not in d:
d[j] = v
else:
d[j] += v
counter = Counter(d.values())
d2 = {3: 0, 5: 0, 15: 0, 25: 0, 75: 0}
for count, v in counter.items():
if count >= 74:
d2[75] += v
if count >= 24:
d2[25] += v
if count >= 14:
d2[15] += v
if count >= 4:
d2[5] += v
if count >= 2:
d2[3] += v
ans = (
d2[75]
+ d2[25] * (d2[3] - 1)
+ d2[15] * (d2[5] - 1)
+ d2[5] * (d2[5] - 1) * (d2[3] - 2) // 2
)
print(ans)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s591996415 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | from collections import defaultdict
from itertools import combinations
# time complexity: O(√n)
def prime_factorize(n, prime_factors=None):
if prime_factors is None:
prime_factors = defaultdict(int)
i = 2
while i * i <= n:
if n % i == 0:
while n % i == 0:
prime_factors[i] += 1
n //= i
i += 1
if n != 1:
prime_factors[n] += 1
return prime_factors
N = int(input())
prime_factors = defaultdict(int)
for n in range(1, N + 1):
prime_factors = prime_factorize(n, prime_factors)
over_primes = defaultdict(list)
for p, e in prime_factors.items():
for threshold in (2, 4, 14, 24, 74):
if e >= threshold:
over_primes[threshold].append(p)
num_shichigos = 0
for p1 in over_primes[2]:
# (2, 4, 4)
for p2_1, p2_2 in combinations(over_primes[4], 2):
if p1 != p2_1 and p1 != p2_2:
num_shichigos += 1
# (2, 24)
for p3 in over_primes[24]:
if p1 != p3:
num_shichigos += 1
for p1 in over_primes[4]:
# (4, 14)
for p2 in over_primes[14]:
if p1 != p2:
num_shichigos += 1
# (74)
num_shichigos += len(over_primes[74])
print(num_shichigos)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s997460876 | Wrong Answer | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
primes = {}
for p in map(
int,
"2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97".split(),
):
primes[p] = 0
factors = {}
for p in primes.keys():
factors[p] = 0
for i in range(1, N + 1):
while i > 1:
for p in primes:
while i % p == 0:
factors[p] = factors.get(p, 0) + 1
i //= p
fact3, fact5, fact15, fact25, fact75 = 0, 0, 0, 0, 0
for k, v in factors.items():
if v >= 75:
fact75 += 1
if v >= 24:
fact25 += 1
if v >= 14:
fact15 += 1
if v >= 4:
fact5 += 1
if v >= 2:
fact3 += 1
print(
fact75
+ fact25 * (fact3 - 1)
+ fact15 * (fact5 - 1)
+ fact5 * (fact5 - 1) * (fact3 - 2) // 2
)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s036851008 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
n = [0]*(N+1)
for i in range(2, N+1):
for j in range(2, i+1):
while i%j == 0:
i//=j
n[j] += 1
def num(m):
return len(list(filter(lambda x: x>=m-1, n)))
print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)14+num(5)*(num(5)-1)*(num(3)-2)//2) | Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s353066511 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
n = [0]*(N+1)
for i in range(2, N+1):
for j in range(2, i+1):
while i%j == 0:
i//=j
n[j] += 1
def num(m):
return len(list(filter(lambda x: x>=m-1, e)))
print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)14+num(5)*(num(5)-1)*(num(3)-2)//2) | Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s856211449 | Wrong Answer | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
print("YES" if N == 3 or N == 5 or N == 7 else "NO")
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s463265868 | Runtime Error | p03213 | Input is given from Standard Input in the following format:
N | n = int(input())
l = [0]*(n+1)
for i in range(2, n+1):
cur = i
for j in range(2, i+1):
while cur % j == 0:
cur //= j
l[j] == 1
def num(s):
return len(list(filter(lambda x: m-1 =< x, l)))
print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+(num(5)*(num(5)-1)*(num(3)-2))//2)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s845422312 | Wrong Answer | p03213 | Input is given from Standard Input in the following format:
N | prime = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
]
print(len(prime))
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s179653144 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | N = int(input())
# N = 100
# 素因数を足し合わせてみる
divisors = [0] * (N + 1)
# 素因数分解(小さい方から順に割っていく)
for j in range(2, N + 1):
s = 0
L = j
while s == 0:
for i in range(2, N + 1):
if L % i == 0:
divisors[i] += 1
L //= i
if L == 1:
s = 1 # 1はこれ以上素因数を産まない
break
# print("{}!:{}".format(j,divisors))
# 3パターン
# 75 * 1 パターン
# 25 * 3 パターン
# 5 * 15 パターン
# 5 * 5 * 3 パターン
list75 = [i for i, div in enumerate(divisors) if 74 <= div and i > 1]
list25 = [i for i, div in enumerate(divisors) if 24 <= div and i > 1]
list15 = [i for i, div in enumerate(divisors) if 14 <= div and i > 1]
list5 = [i for i, div in enumerate(divisors) if 4 <= div and i > 1]
list3 = [i for i, div in enumerate(divisors) if 2 <= div and i > 1]
# list2 = [i for i,div in enumerate(divisors) if 1 <= div and i > 1]
# print(list75)
# print(list25)
# print(list15)
# print(list5)
# print(list3)
# print(len(list75),len(list25),len(list15),len(list5),len(list3))
n75 = len(list75)
n25 = len(list25)
n15 = len(list15)
n5 = len(list5)
n3 = len(list3)
print(n75 + n25 * (n3 - 1) + n15 * (n5 - 1) + n5 * (n5 - 1) // 2 * (n3 - 2))
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s229468280 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | n = int(input())
P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
c = 0
for i in range(15):
a = n
b = 0
while a >= P[i]:
a = a // P[i]
b = b + a
if b >= 74:
c = c + 1
for i in range(15):
a = n
b = 0
while a >= P[i]:
a = a // P[i]
b = b + a
if b >= 24:
d = 0
for j in range(15):
if j == i:
continue
a = n
b = 0
while a >= P[j]:
a = a // P[j]
b = b + a
if b >= 2:
c = c + 1
for i in range(15):
a = n
b = 0
while a >= P[i]:
a = a // P[i]
b = b + a
if b >= 14:
d = 0
for j in range(15):
if j == i:
continue
a = n
b = 0
while a >= P[j]:
a = a // P[j]
b = b + a
if b >= 4:
c = c + 1
for i in range(15):
a = n
b = 0
while a >= P[i]:
a = a // P[i]
b = b + a
if b >= 4:
d = 0
for j in range(i + 1, 15):
if j == i:
continue
a = n
b = 0
while a >= P[j]:
a = a // P[j]
b = b + a
if b >= 4:
d = 0
for k in range(15):
if k == i or k == j:
continue
a = n
b = 0
while a >= P[k]:
a = a // P[k]
b = b + a
if b >= 2:
c = c + 1
print(c)
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Print the number of the Shichi-Go numbers that are divisors of N!.
* * * | s466727137 | Accepted | p03213 | Input is given from Standard Input in the following format:
N | def fac(n): # nは2以上
a = []
t = n
if t % 2 == 0:
count = 0
while t % 2 == 0:
count += 1
t //= 2
a.append([2, count])
for i in range(3, n + 1, 2):
if i * i > n:
break
if t % i == 0:
count = 0
while t % i == 0:
count += 1
t //= i
a.append([i, count])
if t != 1:
a.append([t, 1])
return a
from sys import stdin
def main():
# 入力
readline = stdin.readline
n = int(readline())
d = dict()
for i in range(1, n + 1):
li = fac(i)
for p in li:
if p[0] not in d:
d[p[0]] = p[1]
else:
d[p[0]] += p[1]
cnt_75 = 0
cnt_25 = 0
cnt_15 = 0
cnt_5 = 0
cnt_3 = 0
for v in d.values():
if v >= 74:
cnt_75 += 1
cnt_25 += 1
cnt_15 += 1
cnt_5 += 1
cnt_3 += 1
elif v >= 24:
cnt_25 += 1
cnt_15 += 1
cnt_5 += 1
cnt_3 += 1
elif v >= 14:
cnt_15 += 1
cnt_5 += 1
cnt_3 += 1
elif v >= 4:
cnt_5 += 1
cnt_3 += 1
elif v >= 2:
cnt_3 += 1
ans = 0
ans += cnt_75
ans += cnt_25 * (cnt_3 - 1)
ans += cnt_15 * (cnt_5 - 1)
ans += cnt_5 * (cnt_5 - 1) // 2 * (cnt_3 - 2)
print(ans)
if __name__ == "__main__":
main()
| Statement
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ...
\times N), how many _Shichi-Go numbers_ (literally "Seven-Five numbers") are
there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. | [{"input": "9", "output": "0\n \n\nThere are no Shichi-Go numbers among the divisors of 9! = 1 \\times 2 \\times\n... \\times 9 = 362880.\n\n* * *"}, {"input": "10", "output": "1\n \n\nThere is one Shichi-Go number among the divisors of 10! = 3628800: 32400.\n\n* * *"}, {"input": "100", "output": "543"}] |
Your program has to print the greatest common divisor for each pair of input
numbers. Print each result on a new line. | s716719312 | Runtime Error | p00595 | The input file consists of several lines with pairs of two natural numbers in
each line. The numbers do not exceed 100000.
The number of pairs (datasets) is less than 50. | from math import gcd
while True:
try:
a, b = map(int, input().split())
print(gcd(a, b))
except:
break
| A: Greatest Common Divisor
Please find the greatest common divisor of two natural numbers. A clue is: The
Euclid's algorithm is a way to resolve this task. | [{"input": "38\n 60 84", "output": "12"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s903362506 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | x = int(input())
num = list(map(int, input().split()))
min = num[0]
max = num[0]
for i in range(x):
if num[i] < min:
min = num[i]
if max < num[i]:
max = num[i]
print(min, max, sum(num), sep=" ")
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s430459324 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | ###
### atcorder test program
###
### math class
class math:
### pi
pi = 3.14159265358979323846264338
### GCD
def gcd(self, a, b):
if b == 0:
return a
return self.gcd(b, a % b)
math = math()
### input sample
# i = input()
# A, B, C = [x for x in i.split()]
# R = float(input())
# A = [int(x) for x in input().split()]
### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
N = int(input())
mat = [int(w) for w in input().split()]
print(min(mat), max(mat), sum(mat))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s736300000 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | x = input()
y = input()
list = y.split()
list_i = [int(s) for s in list]
Min = min(list_i)
Max = max(list_i)
Sum = sum(list_i)
mi = str(Min)
ma = str(Max)
su = str(Sum)
sp = " "
ans = mi + sp + ma + sp + su
print(ans)
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s966688887 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | first = input()
hantei = list(map(int, input().split()))
print("{0} {1} {2}".format(min(hantei), max(hantei), sum(hantei)))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s836627379 | Wrong Answer | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = input().split()
a = list(map(int, n))
min_num = min(a)
max_num = max(a)
sum_num = sum(a)
print("{} {} {}".format(min_num, max_num, sum_num))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s876236065 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | s = 0
kei = 0
i = input()
iline = []
iline = input().split(" ")
ilinei = [int(a) for a in iline]
ilinei.sort()
for s in range(int(i)):
kei = kei + int(ilinei[s])
s = int(i) - 1
print(str(ilinei[0]) + " " + str(ilinei[s]) + " " + str(kei))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s433253458 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = int(input())
myValue = list(map(int, input().split(" ")))
myMin = min(myValue)
myMax = max(myValue)
mySum = sum(myValue)
print(myMin, myMax, mySum)
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s521778130 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | num = int(input())
maxi = -1000001
mini = 1000001
total = 0
curr = 0
z = input()
for item in z.split():
curr = int(item)
if curr > maxi:
maxi = curr
if curr < mini:
mini = curr
total += curr
print(str(mini) + " " + str(maxi) + " " + str(total))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s396887567 | Runtime Error | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | date1, date2 = list(map(int, input().split()))
a = min(date1) # 2
b = max(date1) # 50
c = sum(date1) # 256
print(f"{a}")
print(f"{b}")
print(f"{c}")
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s653734131 | Runtime Error | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | LEN = int(input())
mem = []
for i in range(0, LEN):
mem.append(int(input()))
LEN -= 1
if LEN == 0:
break
print(min(mem), max(mem), sum(mem))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s259870672 | Runtime Error | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | array = map(int, input().split())
del array[0]
print(min(array), max(array), sum(array))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s320909291 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = int(input())
nums = [int(i) for i in input().split(" ")]
nums_sorted = sorted(nums)
min = nums_sorted[0]
max = nums_sorted[n - 1]
print(min, max, sum(nums_sorted))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s642473196 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n=int(input())
a=[int(i) for i in input().split()]
print(min(a),max(a),sum(a))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s442351686 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = int(input())
l = [int(x) for x in input().split()]
s = 0
for i in range(len(l)):
s += l[i]
print(min(l), max(l), s)
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s141891126 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | lens = int(input())
numbers = list(map(int, input().split()))
print(f"{min(numbers)} {max(numbers)} {sum(numbers)}")
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s095378048 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = int(input())
s = [int(x) for x in input().split()]
min = min(s)
max = max(s)
sum = sum(s)
print("{} {} {}".format(min, max, sum))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s596940353 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | x = input()
x = input()
x = x.split(" ")
x = [int(z) for z in x]
cmax = -1000000
cmin = 1000000
csum = 0
for z in x:
if cmax < z:
cmax = z
if cmin > z:
cmin = z
csum += z
print("%d %d %d" % (cmin, cmax, csum))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s694070980 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | z = input()
r = input()
a = r.split(" ")
list = []
for i in a:
list.append(int(i))
b = max(list)
c = min(list)
d = sum(list)
print("%s %s %s" % (c, b, d))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print the minimum value, maximum value and sum in a line. Put a single space
between the values. | s424628063 | Accepted | p02402 | In the first line, an integer $n$ is given. In the next line, $n$ integers
$a_i$ are given in a line. | n = int(input())
numbers = input().split()
min_n = int(numbers[0])
max_n = int(numbers[0])
sum_n = int(numbers[0])
for i in range(1, n):
sum_n = sum_n + int(numbers[i])
if min_n > int(numbers[i]):
min_n = int(numbers[i])
if max_n < int(numbers[i]):
max_n = int(numbers[i])
print("{0} {1} {2}".format(min_n, max_n, sum_n))
| Min, Max and Sum
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ...
n)$, and prints the minimum value, maximum value and sum of the sequence. | [{"input": "10 1 5 4 17", "output": "17 37"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s337014569 | Accepted | p02697 | Input is given from Standard Input in the following format:
N M | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# M個用意する対戦場の数字の差が異なるようにする
N, M = lr()
answer = [[0, 0] for _ in range(M)]
if N & 1:
for i in range(M):
answer[i][0] = i + 1
cur = M + 1
used = set()
for i in range(M - 1, -1, -1):
while cur - answer[i][0] in used:
cur += 1
answer[i][1] = cur
diff = answer[i][1] - answer[i][0]
used.add(diff)
cur += 1
else:
l = list(range(1, M + 1))
odd = [x for x in l if x & 1]
even = [x for x in l if x % 2 == 0]
cur = 0
for x in odd[::-1]:
answer[cur] = [cur + 1, cur + 1 + x]
cur += 1
now = 1 + odd[-1] + 1
for x in even[::-1]:
answer[cur] = [now, now + x]
now += 1
cur += 1
for a in answer:
if a[0] == 0:
continue
print(*a)
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s596696619 | Runtime Error | p02697 | Input is given from Standard Input in the following format:
N M | # coding: utf-8
import math
N, M = map(int, input().split())
# 素数判定関数
def isPrime(num):
# 2未満の数字は素数ではない
if num < 2:
return False
# 2は素数
elif num == 2:
return True
# 偶数は素数ではない
elif num % 2 == 0:
return False
# 3 ~ numまでループし、途中で割り切れる数があるか検索
# 途中で割り切れる場合は素数ではない
for i in range(3, math.floor(math.sqrt(num)) + 1, 2):
if num % i == 0:
return False
# 素数
return True
# 素数判定
def callIsPrime(input_num=1000):
numbers = []
# ループしながら素数を検索する
for i in range(1, input_num):
if isPrime(i):
numbers.append(i)
# 素数配列を返す
return numbers
used = [False for i in range(N + 1)]
P = callIsPrime(100000)
L = [1]
L.extend(P)
for i in range(len(L)):
if L[i] > N - 1:
index = i - 1
break
cnt = 1
C = 0
while True:
if not used[cnt] and not used[cnt + L[index - C - 1]]:
print(cnt, cnt + L[index - C - 1])
used[cnt] = True
used[cnt + L[index - C - 1]] = True
C += 1
if C == M:
break
cnt += 1
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s407360683 | Wrong Answer | p02697 | Input is given from Standard Input in the following format:
N M | n, m = map(int, input().split())
h = n - m * 2
a = [i for i in range(1, m + 1)]
b = [m + i for i in reversed(range(1, m + 1))]
if h % 2 == 0:
for i in range(m):
b[i] += 1
for i in range(m):
print(a[i], b[i])
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s436549581 | Accepted | p02697 | Input is given from Standard Input in the following format:
N M | n, m = map(int, input().split())
if m % 2 == 1:
# for i in range(m):
# print(str(i+1) + ' ' + str(2*m-i))
for i in range(int((m - 1) / 2)):
print(str(i + 1) + " " + str(m - i))
for i in range(int((m + 1) / 2)):
print(str(m + i + 1) + " " + str(2 * m - i + 1))
else:
for i in range(int(m / 2)):
print(str(i + 1) + " " + str(m - i + 1))
for i in range(int(m / 2)):
print(str(i + m + 2) + " " + str(2 * m - i + 1))
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s493066007 | Accepted | p02697 | Input is given from Standard Input in the following format:
N M | n, m = list(map(int, input().split()))
mm = int((m + 1) / 2 + 0.01)
for i in range(mm):
print(1 + i, 2 * mm - i)
for i in range(m - mm):
print(2 * mm + i + 1, 2 * m - i + 1)
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s268379424 | Wrong Answer | p02697 | Input is given from Standard Input in the following format:
N M | import sys
def Ii():
return int(sys.stdin.buffer.readline())
def Mi():
return map(int, sys.stdin.buffer.readline().split())
def Li():
return list(map(int, sys.stdin.buffer.readline().split()))
n, m = Mi()
a = [0] * (n)
for i in range(m // 2 + 1):
a[i] = 1
a[n // 2 - i] = 1
print(i + 1, n // 2 - i + 1)
for i in range(m // 2):
a[n // 2 + i + 1] = 1
a[n - i - 1] = 1
print(n // 2 + 1 + i + 1, n - i + 1)
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s496030392 | Accepted | p02697 | Input is given from Standard Input in the following format:
N M | n, m = map(int, input().split())
mod = lambda x: x % n + 1
for i in range((m + 1) // 2):
print(mod(-i - (m + 1) // 2), mod(i + 1 - (m + 1) // 2))
for i in range(m // 2):
print(mod(-i + m // 2), mod(i + 2 + m // 2))
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s682497524 | Wrong Answer | p02697 | Input is given from Standard Input in the following format:
N M | nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
start = 0
end = 1
gap = 1
for i in range(m):
print(str(start) + " " + str(end))
gap += 1
start = end % n + 1
end = (start + gap - 1) % n + 1
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s393626181 | Wrong Answer | p02697 | Input is given from Standard Input in the following format:
N M | ###
# main
if __name__ == "__main__":
# input
n, m = map(int, input().split(" "))
for i in range(m):
print(str(n // 2 - i) + " " + str(n // 2 + i + 1))
# output
# print(ans)
# else:
# do nothing
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print M lines in the format below. The i-th line should contain the two
integers a_i and b_i assigned to the i-th playing field.
a_1 b_1
a_2 b_2
:
a_M b_M
* * * | s274776567 | Runtime Error | p02697 | Input is given from Standard Input in the following format:
N M | from sys import stdin
input = stdin.readline
a, b, n = map(int, input().split())
maxpoint = 0
if b > n:
tmp = int((a * n) / b) - a * int(n / b)
maxpoint = max(tmp, maxpoint)
elif b == n:
maxpoint = 0
else:
tmp = int((a * n) / b) - a * int(n / b)
k = int(n / b) * b - 1
t1 = int((a * k) / b) - a * int(k / b)
maxpoint = max(t1, tmp)
# for i in reversed(range(n+1)):
# t1 = int((a * i) / b) - a * int(i/b)
# if b > 1:
# if i == k :
# print(maxpoint)
# exit()
# elif b == 1:
# print(0)
# exit()
# if t1 > maxpoint:
# maxpoint = t1
# print(tmp)
# print(k)
# maxpoint = max(tmp,k)
print(maxpoint)
| Statement
You are going to hold a competition of one-to-one game called AtCoder Janken.
_(Janken is the Japanese name for Rock-paper-scissors.)_ N players will
participate in this competition, and they are given distinct integers from 1
through N. The arena has M playing fields for two players. You need to assign
each playing field two distinct integers between 1 and N (inclusive). You
cannot assign the same integer to multiple playing fields. The competition
consists of N rounds, each of which proceeds as follows:
* For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.
* Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.
You want to ensure that no player fights the same opponent more than once
during the N rounds. Print an assignment of integers to the playing fields
satisfying this condition. It can be proved that such an assignment always
exists under the constraints given. | [{"input": "4 1", "output": "2 3\n \n\nLet us call the four players A, B, C, and D, and assume that they are\ninitially given the integers 1, 2, 3, and 4, respectively.\n\n * The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.\n\n * The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.\n\n * The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.\n\n * The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.\n\nNo player fights the same opponent more than once during the four rounds, so\nthis solution will be accepted.\n\n* * *"}, {"input": "7 3", "output": "1 6\n 2 5\n 3 4"}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s920132473 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | #
# abc122 b
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """ATCODER"""
output = """3"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """HATAGAYA"""
output = """5"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """SHINJUKU"""
output = """0"""
self.assertIO(input, output)
def resolve():
S = input()
ans = 0
# for i in range(len(S)):
# t = 0
# if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
# t += 1
# for j in range(i+1, len(S)):
# if S[j] == "A" or S[j] == "C" or S[j] == "G" or S[j] == "T":
# t += 1
# else:
# break
# ans = max(ans, t)
ans = 0
for i in range(len(S)):
for j in range(i + 1, len(S)):
if S[i:j].count("A") + S[i:j].count("C") + S[i:j].count("G") + S[i:j].count(
"T"
) == len(S[i:j]):
ans = max(ans, len(S[i:j]))
print(ans)
if __name__ == "__main__":
# unittest.main()
resolve()
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s549004044 | Accepted | p03086 | Input is given from Standard Input in the following format:
S | items = ["A", "C", "G", "T"]
def max(a, b):
return a if a > b else b
x = 0
y = 0
for c in list(input()):
if c in items:
y += 1
x = max(x, y)
else:
y = 0
print(x)
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s608144046 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | a = [i for i in input()]
print(a.count("A") + a.count("C") + a.count("G") + a.count("T"))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s286528870 | Accepted | p03086 | Input is given from Standard Input in the following format:
S | import sys
# import bisect
# import math
# import itertools
# import numpy as np
# import collections
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
"""
return int(self.input())
def S(self):
"""
1文字の取得(str
:return: str
"""
return self.input()
def IL(self):
"""
1行を空白で区切りリストにします(int
:return: リスト
"""
return list(map(int, self.input().split()))
def SL(self):
"""
1行の文字列を空白区切りでリストにします
:return: リスト
"""
return list(map(str, self.input().split()))
def ILS(self, n):
"""
1列丸々取得します(int
:param n: 行数
:return: リスト
"""
return [int(self.input()) for _ in range(n)]
def SLS(self, n):
"""
1列丸々取得します(str
:param n: 行数
:return: リスト
"""
return [self.input() for _ in range(n)]
def SILS(self, n):
"""
Some Int LineS
横に複数、縦にも複数
:param n: 行数
:return: list
"""
return [self.IL() for _ in range(n)]
def SSLS(self, n):
"""
Some String LineS
:param n: 行数
:return: list
"""
return [self.SL() for _ in range(n)]
class Idea:
def __init__(self):
pass
def HF(self, p):
"""
Half enumeration
半分全列挙です
pの要素の和の組み合わせを作ります。
ソート、重複削除行います
:param p: list : 元となるリスト
:return: list : 組み合わせられた和のリスト
"""
return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))
def Bfs2(self, a):
"""
bit_full_search2
bit全探索の改良版
全探索させたら2進数のリストと10進数のリストを返す
:return: list2つ : 1個目 2進数(16桁) 2個目 10進数
"""
# 参考
# https://blog.rossywhite.com/2018/08/06/bit-search/
# https://atcoder.jp/contests/abc105/submissions/4088632
value = []
for i in range(1 << len(a)):
output = []
for j in range(len(a)):
if self.bit_o(i, j):
"""右からj+1番目のiが1かどうか判定"""
# output.append(a[j])
output.append(a[j])
value.append([format(i, "b").zfill(16), sum(output)])
value.sort(key=lambda x: x[1])
bin = [value[k][0] for k in range(len(value))]
val = [value[k][1] for k in range(len(value))]
return bin, val
def S(self, s, r=0, m=-1):
"""
ソート関係行います。色々な設定あります。
:param s: 元となるリスト
:param r: reversするかどうか 0=False 1=True
:param m: (2次元配列)何番目のインデックスのソートなのか
:return: None
"""
r = bool(r)
if m == -1:
s.sort(reverse=r)
else:
s.sort(reverse=r, key=lambda x: x[m])
def bit_n(self, a, b):
"""
bit探索で使います。0以上のときにTrue出します
自然数だからn
:param a: int
:param b: int
:return: bool
"""
return bool((a >> b & 1) > 0)
def bit_o(self, a, b):
"""
bit探索で使います。1のときにTrue出すよ
oneで1
:param a: int
:param b: int
:return: bool
"""
return bool(((a >> b) & 1) == 1)
def ceil(self, x, y):
"""
Round up
小数点切り上げ割り算
:param x: int
:param y: int
:return: int
"""
return -(-x // y)
def ave(self, a):
"""
平均を求めます
:param a: list
:return: int
"""
return sum(a) / len(a)
def gcd(self, x, y):
if y == 0:
return x
else:
return self.gcd(y, x % y)
"""ここからメインコード"""
def main():
# 1文字に省略
r, e = range, enumerate
ip = IP()
id = Idea()
"""この下から書いてね"""
s = ip.S()
ans = 0
for i in r(len(s)):
res = 0
if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
res += 1
for j in r(1, len(s) - i):
if (
s[i + j] == "A"
or s[i + j] == "T"
or s[i + j] == "C"
or s[i + j] == "G"
):
res += 1
else:
break
ans = max(ans, res)
else:
pass
print(ans)
main()
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s629169576 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | s_list = list(input())
str_list = ["A", "C", "G", "T"]
now_max = 0
for i, s in enumerate(s_list):
if s in str_list:
l = 1
for next in s_list[i + 1 :]:
if next in str_list:
l += 1
else:
now_max = max(l, now_max)
print(now_max)
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s469846716 | Accepted | p03086 | Input is given from Standard Input in the following format:
S | input = input().strip()
max = 0
max_tmp = 0
for i in range(len(input)):
s = input[i]
if s not in ["A", "T", "C", "G"]:
max_tmp = 0
continue
max_tmp += 1
if max_tmp > max:
max = max_tmp
print(max)
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s559572748 | Accepted | p03086 | Input is given from Standard Input in the following format:
S | S = input()
N = len(S)
max_n = 0
for n in range(N):
for m in range(n, N):
s = S[n : m + 1]
if all("ATCG".count(ss) == 1 for ss in s):
max_n = max(max_n, len(s))
print(max_n)
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s789727109 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | S = "".join([i if i in "ACGT" else " " for i in input()])
print(max([len(i) for i in S.split()]))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s285136851 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | s=list(input())
cnt=0
ans=0
lis=["ATCG"]
for i in range(len(s)):
if s[i] in lis:
cnt+=1
ans=max(ans,cnt):
else:
cnt=0
print(ans) | Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s964045897 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | moji = str(input()) # 文字列の入力
ListNum = [] # suuの各値を入れる
suu = 0
for i in range(0, len(moji), 1):
if moji[i] == "A":
suu += 1
elif moji[i] == "T":
suu += 1
elif moji[i] == "G":
suu += 1
elif moji[i] == "C":
suu += 1
else:
ListNum.append(suu)
suu = 0
print(max(ListNum))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s042486054 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | S = input()
M1 = int(S.rfind("A") - S.find("C") + 1)
M2 = int(S.rfind("A") - S.find("G") + 1)
M3 = int(S.rfind("A") - S.find("T") + 1)
M4 = int(S.rfind("A") - S.find("A") + 1)
M5 = int(S.rfind("C") - S.find("C") + 1)
M6 = int(S.rfind("C") - S.find("A") + 1)
M7 = int(S.rfind("C") - S.find("G") + 1)
M8 = int(S.rfind("C") - S.find("T") + 1)
M9 = int(S.rfind("G") - S.find("G") + 1)
M10 = int(S.rfind("G") - S.find("C") + 1)
M11 = int(S.rfind("G") - S.find("A") + 1)
M12 = int(S.rfind("G") - S.find("T") + 1)
M13 = int(S.rfind("T") - S.find("C") + 1)
M14 = int(S.rfind("T") - S.find("A") + 1)
M15 = int(S.rfind("T") - S.find("G") + 1)
M16 = int(S.rfind("T") - S.find("T") + 1)
print(max(M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, M11, M12, M13, M14, M15, M16))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s062341132 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | def function(S):
ACGT = ['A', 'C', 'G, 'T']
ret = 0
N = len(S)
for i in range(0, N):
for j in range(i+1, N+1):
temp = 0
l = S[i:j]
for x in l:
if x not in ACGT:
break
temp = len(l)
if temp >= ret:
ret = temp
return ret | Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s169634975 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | s=input()
n=len(s)
ans=0
for i in range(n):
for j in range(i,n):
bubun=s[i:j+1]
flag=True
for c in bubun:
if(c not in ['A','G','C','T']):
flag = False
if(flag):
ans = max(ans,len(bubun))
print(ans)
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s795514169 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | def tasu(i):
global bubun
if i >= len(string):
return
elif string[i] == "A" or string[i] == "C" or string[i] == "G" or string[i] == "T":
bubun += string[i]
tasu(i + 1)
string = input()
lst = [""]
for i in range(len(string)):
if string[i] == "A" or string[i] == "C" or string[i] == "G" or string[i] == "T":
bubun = ""
tasu(i)
lst.append(bubun)
print(len(max(lst)))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s694105368 | Runtime Error | p03086 | Input is given from Standard Input in the following format:
S | def actual(s):
sub_string_list = []
N = len(s)
for i in range(N):
for j in range(N - 1):
sub_string_list.append(s[i:j])
set_ACGT = {"A", "C", "G", "T"}
length_list = []
for sub_string in sub_string_list:
if set(sub_string).issubset(set_ACGT):
length_list.append(len(sub_string))
return max(length_list)
s = input()
print(actual(s))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
Print the length of the longest _ACGT string_ that is a substring of S.
* * * | s086862697 | Wrong Answer | p03086 | Input is given from Standard Input in the following format:
S | S = list(input())
N = len(S)
B = ["A", "C", "G", "T"]
c = []
d = [0]
g = 1
for i in range(1, N):
if S[i] in B and S[i - 1] in B:
g += 1
d.append(g)
elif S[i - 1] in B or S[-1] in B:
d.append(g)
print(max(d))
| Statement
You are given a string S consisting of uppercase English letters. Find the
length of the longest _ACGT string_ that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than `A`,
`C`, `G` and `T`. | [{"input": "ATCODER", "output": "3\n \n\nAmong the ACGT strings that are substrings of `ATCODER`, the longest one is\n`ATC`.\n\n* * *"}, {"input": "HATAGAYA", "output": "5\n \n\nAmong the ACGT strings that are substrings of `HATAGAYA`, the longest one is\n`ATAGA`.\n\n* * *"}, {"input": "SHINJUKU", "output": "0\n \n\nAmong the ACGT strings that are substrings of `SHINJUKU`, the longest one is\n`` (the empty string)."}] |
For each dataset, output a single line containing two positive integers
representing the plan with the maximal number of vertically adjacent floors
with its rent price exactly equal to the budget of Mr. Port. The first should
be the lowest floor number and the second should be the number of floors. | s162062198 | Accepted | p01111 | The input consists of multiple datasets, each in the following format.
> _b_
>
A dataset consists of one line, the budget of Mr. Port _b_ as multiples of the
rent of the first floor. _b_ is a positive integer satisfying 1 < _b_ < 109.
The end of the input is indicated by a line containing a zero. The number of
datasets does not exceed 1000. | while True:
b = int(input())
if b == 0:
break
x = b * 2
for k in range(int(x ** (1 / 2)), 0, -1):
if x % k == 0:
if (-k + 1 + (x // k)) % 2 == 0:
a = (-k + 1 + x // k) // 2
if a > 0:
print(a, k)
break
| Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors of the new
skyscraper with one giga floors, MinatoHarukas. He wants to rent as many
vertically adjacent floors as possible, because he wants to show advertisement
on as many vertically adjacent windows as possible. The rent for one floor is
proportional to the floor number, that is, the rent per month for the _n_ -th
floor is _n_ times that of the first floor. Here, the ground floor is called
the first floor in the American style, and basement floors are out of
consideration for the renting. In order to help Mr. Port, you should write a
program that computes the vertically adjacent floors satisfying his
requirement and whose total rental cost per month is _exactly equal_ to his
budget.
For example, when his budget is 15 units, with one unit being the rent of the
first floor, there are four possible rent plans, 1+2+3+4+5, 4+5+6, 7+8, and
15. For all of them, the sums are equal to 15. Of course in this example the
rent of maximal number of the floors is that of 1+2+3+4+5, that is, the rent
from the first floor to the fifth floor. | [{"input": "16\n 2\n 3\n 9699690\n 223092870\n 847288609\n 900660121\n 987698769\n 999999999\n 0", "output": "5\n 16 1\n 2 1\n 1 2\n 16 4389\n 129 20995\n 4112949 206\n 15006 30011\n 46887 17718\n 163837 5994"}] |
For each dataset, output a single line containing two positive integers
representing the plan with the maximal number of vertically adjacent floors
with its rent price exactly equal to the budget of Mr. Port. The first should
be the lowest floor number and the second should be the number of floors. | s285414644 | Runtime Error | p01111 | The input consists of multiple datasets, each in the following format.
> _b_
>
A dataset consists of one line, the budget of Mr. Port _b_ as multiples of the
rent of the first floor. _b_ is a positive integer satisfying 1 < _b_ < 109.
The end of the input is indicated by a line containing a zero. The number of
datasets does not exceed 1000. | import sys
while True:
n = int(sys.stdin.readline())
if not n:
break
head = tail = 1
s = 0
while True:
while s < n:
s += tail
tail += 1
while s > n:
s -= head
head += 1
if s == n:
sys.stdout.write("%d %d\n" % (head, tail - head))
break
| Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors of the new
skyscraper with one giga floors, MinatoHarukas. He wants to rent as many
vertically adjacent floors as possible, because he wants to show advertisement
on as many vertically adjacent windows as possible. The rent for one floor is
proportional to the floor number, that is, the rent per month for the _n_ -th
floor is _n_ times that of the first floor. Here, the ground floor is called
the first floor in the American style, and basement floors are out of
consideration for the renting. In order to help Mr. Port, you should write a
program that computes the vertically adjacent floors satisfying his
requirement and whose total rental cost per month is _exactly equal_ to his
budget.
For example, when his budget is 15 units, with one unit being the rent of the
first floor, there are four possible rent plans, 1+2+3+4+5, 4+5+6, 7+8, and
15. For all of them, the sums are equal to 15. Of course in this example the
rent of maximal number of the floors is that of 1+2+3+4+5, that is, the rent
from the first floor to the fifth floor. | [{"input": "16\n 2\n 3\n 9699690\n 223092870\n 847288609\n 900660121\n 987698769\n 999999999\n 0", "output": "5\n 16 1\n 2 1\n 1 2\n 16 4389\n 129 20995\n 4112949 206\n 15006 30011\n 46887 17718\n 163837 5994"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s457857527 | Accepted | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
# from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
AtoZ = "abcdefghijklmnopqrstuvwxyz"
#############
# Functions #
#############
######INPUT######
def I():
return int(input().strip())
def S():
return input().strip()
def IL():
return list(map(int, input().split()))
def SL():
return list(map(str, input().split()))
def ILs(n):
return list(int(input()) for _ in range(n))
def SLs(n):
return list(input().strip() for _ in range(n))
def ILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def SLL(n):
return [list(map(str, input().split())) for _ in range(n)]
######OUTPUT######
def P(arg):
print(arg)
return
def Y():
print("Yes")
return
def N():
print("No")
return
def E():
exit()
def PE(arg):
print(arg)
exit()
def YE():
print("Yes")
exit()
def NE():
print("No")
exit()
#####Shorten#####
def DD(arg):
return defaultdict(arg)
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####MakeDivisors######
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
#####MakePrimes######
def make_primes(N):
max = int(math.sqrt(N))
seachList = [i for i in range(2, N + 1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
#####GCD#####
def gcd(a, b):
while b:
a, b = b, a % b
return a
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def count_bit(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#####ChangeBase#####
def base_10_to_n(X, n):
if X // n:
return base_10_to_n(X // n, n) + [X % n]
return [X % n]
def base_n_to_10(X, n):
return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X))))
#####IntLog#####
def int_log(n, a):
count = 0
while n >= a:
n //= a
count += 1
return count
#############
# Main Code #
#############
H, W = IL()
dic = DD(int)
for _ in range(H):
s = S()
for x in s:
dic[x] += 1
data = []
for a in AtoZ:
if dic[a] % 4 != 0:
data.append(dic[a] % 4)
c = DD(int)
for d in data:
c[d] += 1
if H % 2 and W % 2:
if c[1] == 1 and c[2] <= H // 2 + W // 2 and c[3] == 0:
print("Yes")
elif c[3] == 1 and c[2] <= H // 2 + W // 2 - 1 and c[1] == 0:
print("Yes")
else:
print("No")
elif H % 2:
if c[1] == c[3] == 0 and c[2] <= W // 2:
print("Yes")
else:
print("No")
elif W % 2:
if c[1] == c[3] == 0 and c[2] <= H // 2:
print("Yes")
else:
print("No")
else:
if data == []:
print("Yes")
else:
print("No")
| Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s694167977 | Wrong Answer | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0] + list(accumulate(lst))
sys.setrecursionlimit(500000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
h, w = map(int, input().split())
a = [input() for i in range(h)]
lst = [0] * 26
for i in range(h):
for j in range(w):
lst[ord(a[i][j]) - ord("a")] -= 1
print(lst)
heapq.heapify(lst)
dic = defaultdict(int)
if h % 2 == 0:
if w % 2 == 0:
dic[4] = h * w // 4
else:
dic[4] = (w - 1) * h // 4
dic[2] = h // 2
else:
if w % 2 == 0:
dic[4] = (h - 1) * w // 4
dic[2] = w // 2
else:
dic[4] = (h - 1) * (w - 1)
dic[2] = h // 2 + w // 2
dic[1] = 1
# print(dic)
# print(lst)
for i in range(dic[4]):
tmp = -heapq.heappop(lst)
if tmp >= 4:
tmp -= 4
heapq.heappush(lst, -tmp)
else:
print("No")
quit()
for i in range(dic[2]):
tmp = -heapq.heappop(lst)
if tmp >= 2:
tmp -= 2
heapq.heappush(lst, -tmp)
else:
print("No")
quit()
for i in range(dic[1]):
tmp = -heapq.heappop(lst)
if tmp >= 1:
tmp -= 1
heapq.heappush(lst, -tmp)
else:
print("No")
quit()
# print(lst)
print("Yes")
| Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s554022910 | Wrong Answer | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | H, W = map(int, input().split())
A = []
if W == 1:
for h in range(H):
A.append(input())
else:
for h in range(H):
for w in list(input()):
A.append(w)
from collections import Counter
data = Counter(A)
ok = True
if W % 2 == 1 and H % 2 == 1:
flag_4 = False
get_quad = 0
for i in data:
# can get 4
while data[i] // 4 >= 1 and flag_4 == False:
# want 4
if get_quad < (W - 1) * (H - 1) / 4:
data[i] -= 4
get_quad += 1
if get_quad == (W - 1) * (H - 1) / 4:
flag_4 = True
if flag_4 == False:
print("No")
ok = False
get_double = 0
flag_2 = False
for i in data:
# can get 2
while data[i] // 2 >= 1 and flag_2 == False:
# want 4
if get_quad < (W + H - 2) / 2:
data[i] -= 2
get_double += 1
if get_quad == (W + H - 2) / 2:
flag_2 = True
if flag_2 == False:
print("No")
ok = False
elif W % 2 == 1 and H % 2 == 0:
flag_4 = False
get_quad = 0
for i in data:
# can get 4
while data[i] // 4 >= 1 and flag_4 == False:
# want 4
if get_quad < (W - 1) * (H) / 4:
data[i] -= 4
get_quad += 1
if get_quad == (W - 1) * (H) / 4:
flag_4 = True
if flag_4 == False:
print("No")
ok = False
get_double = 0
flag_2 = False
for i in data:
# can get 2
while data[i] // 2 >= 1 and flag_2 == False:
# want 4
if get_quad < (H) / 2:
data[i] -= 2
get_double += 1
if get_quad == (H) / 2:
flag_2 = True
if flag_2 == False:
print("No")
ok = False
elif W % 2 == 0 and H % 2 == 1:
flag_4 = False
get_quad = 0
for i in data:
# can get 4
while data[i] // 4 >= 1 and flag_4 == False:
# want 4
if get_quad < (H - 1) * (W) / 4:
data[i] -= 4
get_quad += 1
if get_quad == (H - 1) * (W) / 4:
flag_4 = True
if flag_4 == False:
print("No")
ok = False
get_double = 0
flag_2 = False
for i in data:
# can get 2
while data[i] // 2 >= 1 and flag_2 == False:
# want 4
if get_quad < (W) / 2:
data[i] -= 2
get_double += 1
if get_quad == (W) / 2:
flag_2 = True
if flag_2 == False:
print("No")
ok = False
elif W % 2 == 0 and H % 2 == 0:
flag_4 = False
get_quad = 0
for i in data:
# can get 4
while data[i] // 4 >= 1 and flag_4 == False:
# want 4
if get_quad < (H) * (W) / 4:
data[i] -= 4
get_quad += 1
if get_quad == (H - 1) * (W) / 4:
flag_4 = True
if flag_4 == False:
print("No")
ok = False
get_double = 0
flag_2 = False
for i in data:
# can get 2
while data[i] // 2 >= 1 and flag_2 == False:
# want 4
if get_quad < (W) / 2:
data[i] -= 2
get_double += 1
if get_quad == (W) / 2:
flag_2 = True
if flag_2 == False:
print("No")
ok = False
if ok:
print("Yes")
| Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s633295174 | Accepted | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | h, w = map(int, input().split())
alphcnt = [0] * 26
for _ in range(h):
a = list(input())
for x in a:
alphcnt[ord(x) - 97] += 1
p1, p2, p4 = 0, 0, 0
for i in range(26):
x = alphcnt[i] // 4
alphcnt[i] -= 4 * x
p4 += x
for i in range(26):
x = alphcnt[i] // 2
alphcnt[i] -= 2 * x
p2 += x
for i in range(26):
x = alphcnt[i]
alphcnt[i] -= x
p1 += x
t = 0
if h % 2 == w % 2 == 0:
if p1 == p2 == 0:
t = 1
elif h % 2 == w % 2 == 1:
if p1 == 1 and p4 >= (h // 2) * (w // 2):
t = 1
else:
if p1 == 0 and p4 >= (h // 2) * (w // 2):
t = 1
print("Yes" if t == 1 else "No")
| Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s364678913 | Accepted | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | import sys
from collections import defaultdict, Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode("utf-8")
def main():
H, W = in_nn()
a = []
for i in range(H):
a += list(in_s())
mH = -(-H // 2)
mW = -(-W // 2)
nums = defaultdict(int)
for y in range(mH):
for x in range(mW):
if x == W - x - 1 and y == H - y - 1:
n = 1
elif x == W - x - 1:
n = 2
elif y == H - y - 1:
n = 2
else:
n = 4
nums[n] += 1
count = Counter(a)
td = defaultdict(int)
for v in count.values():
for n in (4, 2, 1):
if v >= n:
if td[n] < nums[n]:
c = min(v // n, nums[n] - td[n])
td[n] += c
v -= n * c
# print(nums)
# print(td)
ans = "Yes"
for n in (4, 2, 1):
if td[n] != nums[n]:
ans = "No"
break
print(ans)
if __name__ == "__main__":
main()
| Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
If Snuke can create a matrix satisfying the condition, print `Yes`; otherwise,
print `No`.
* * * | s590030446 | Runtime Error | p03593 | Input is given from Standard Input in the following format:
H W
a_{11}a_{12}...a_{1W}
:
a_{H1}a_{H2}...a_{HW} | from collections import Counter
h, w = map(int, input().split())
A = []
for i in range(h):
A.extend(list(input()))
cA = Counter(A)
l1 = h*w%2
l2 = (h//2)*(w%2) + (w//2)*(h%2)
l3 = (h//2)*(w//2)
if l1:
for key, val in cA.items():
if val%2==1:
cA[key] -= 1
break
for _ in range(l2):
for key, val in cA.items():
if val%4=-2:
cA[key] -= 2
break
print('Yes' if sum(val%4 for val in cA.values()) == 0 else 'No') | Statement
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the
top and j-th column from the left. In this matrix, each a_{ij} is a lowercase
English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the
elements in A. Here, he wants to satisfy the following condition:
* Every row and column in A' can be read as a palindrome.
Determine whether he can create a matrix satisfying the condition. | [{"input": "3 4\n aabb\n aabb\n aacc", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n abba\n acca\n abba\n \n\n* * *"}, {"input": "2 2\n aa\n bb", "output": "No\n \n\nIt is not possible to create a matrix satisfying the condition, no matter how\nwe rearrange the elements in A.\n\n* * *"}, {"input": "5 1\n t\n w\n e\n e\n t", "output": "Yes\n \n\nFor example, the following matrix satisfies the condition.\n\n \n \n t\n e\n w\n e\n t\n \n\n* * *"}, {"input": "2 5\n abxba\n abyba", "output": "No\n \n\n* * *"}, {"input": "1 1\n z", "output": "Yes"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.