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
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s482123397
Accepted
p03329
Input is given from Standard Input in the following format: N
N = int(input()) B = [pow(6, i) for i in range(1, 10) if pow(6, i) <= N] C = [pow(9, i) for i in range(1, 10) if pow(9, i) <= N] A = sorted(B + C + [1]) L = len(A) DP = [[N] * (N + 1) for i in range(L)] DP[0] = [i for i in range(N + 1)] for l in range(1, L): k = A[l] for n in range(0, k): DP[l][n] = DP[l - 1][n] for n in range(k, N + 1): DP[l][n] = min(DP[l - 1][n - k] + 1, DP[l][n - k] + 1, DP[l - 1][n]) print(DP[L - 1][N])
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s729022362
Accepted
p03329
Input is given from Standard Input in the following format: N
N = int(input()) # 6,9の累乗のリスト sixs = [] t = 1 while t <= N: sixs.append(t) t *= 6 nines = [] t = 1 while t <= N: nines.append(t) t *= 9 ans = N # aを6の指数乗、N-aを9の指数乗で支払う for i in range(N + 1): cnt = 0 a = i b = N - i for num in list(reversed(sixs)): if a == 0: break elif a <= 5: cnt += a a = 0 else: if a >= num: # if a == 36: print(a // num, num) tmp = a // num cnt += tmp a -= num * tmp # if i == 36: print(a,cnt) else: continue # if i == 36: print(cnt) for num in list(reversed(nines)): if b == 0: break elif b <= 8: cnt += b b = 0 else: if b >= num: tmp = b // num cnt += tmp b -= num * tmp else: continue ans = min(ans, cnt) print(ans)
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s467763041
Runtime Error
p03329
Input is given from Standard Input in the following format: N
money = int(input()) six = 1 nine = 1 now = 1 kingaku = [1] while money > now: if pow(6, six) < pow(9, nine): now = pow(6, six) six += 1 else: now = pow(9, nine) nine += 1 kingaku.append(now) kingaku.pop() count = 0 def check(money, lis, idx, count): m = lis[idx] if money < 0: return 1000000 if idx < 0: return count if idx == 0: return count + money if money < m: return check(money, lis, idx - 1, count) sho = money // m mini = 1000000 for i in range(sho + 1): value = check(money - m * i, lis, idx - 1, count + i) if value < mini: mini = value return mini print(check(money, kingaku, len(kingaku) - 1, 0))
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s974019173
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
n = int(input()) ar = [] for l in range(2): # 59049 abc = n - (59049 * l) if abc < 0: break for k in range(3): # 46656 abc = n - (46656 * k + 59049 * l) if abc < 0: break for j in range(6): # 7776 abc = n - (776 * j + 46656 * k + 59049 * l) if abc < 0: break for h in range(3): # 1296,6 abc = n - (1296 * h + 7776 * j + 46656 * k + 59049 * l) if abc < 0: break for g in range(4): # 729,9 abc = n - (729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l) if abc < 0: break for f in range(3): # 216,5(4) abc = n - ( 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break for e in range(4): # 81 abc = n - ( 81 * e + 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break for d in range(5): # 36 abc = n - ( 36 * d + 81 * e + 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break for c in range(4): # 9 abc = n - ( 9 * c + 36 * d + 81 * e + 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break for b in range(3): # 6 abc = n - ( 6 * b + 9 * c + 36 * d + 81 * e + 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break for a in range(6): # 1 abc = n - ( 1 * a + 6 * b + 9 * c + 36 * d + 81 * e + 216 * f + 729 * g + 1296 * h + 7776 * j + 46656 * k + 59049 * l ) if abc < 0: break if abc % 6561 == 0 and abc >= 0: i = abc // 6561 ar.append( a + b + c + d + e + f + g + h + i + j + k + l ) print(min(ar))
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s327850316
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
n_max = 100000 bs = [(6**i, 6) for i in range(1, 10)] bs.extend([(9**i, 9) for i in range(1, 10)]) bs = list(sorted(filter(lambda x: x[0] <= n_max, bs))) bms = [] s = 5 for b, i in bs: s += b * (i - 1) bms.append((b, i, s)) # print(bs) # print(bms, len(bms)) # m = 44852 m = int(input()) stack = [(m, 0, len(bms) - 1)] # print("search start!") result = 10000 while stack: m, n, bms_i = stack.pop() b, i, s = bms[bms_i] # print(m, n, bms_i, b, i, s) if n > result: # print("skip!", m, n, bms_i) continue if bms_i < 0: if m < 6 and result > m + n: result = m + n # print('get result!', result) continue for j in range(0, i): next_m = m - b * j if next_m > 0 and n + j < result: stack.append((next_m, n + j, bms_i - 1)) print(result)
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s798044123
Accepted
p03329
Input is given from Standard Input in the following format: N
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x) - 1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 inf = float("INF") # A def A(): return # B def B(): return # C def C(): n = II() dp = [inf for i in range(n + 1)] ans = [1] x = 6 while x <= n: ans.append(x) x = x * 6 x = 9 while x <= n: ans.append(x) x = x * 9 ans.sort() for i in ans: dp[i] = 1 for i in range(1, n + 1): if not i in ans: a = bisect.bisect_left(ans, i) for k in range(a): # print(i,ans[k], a) dp[i] = min(dp[i - ans[k]] + 1, dp[i]) print(dp[n]) return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": C()
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s024658885
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
n = int(input()) ans = 10**10 dp = [0] * 100001 for i in range(1, n + 1): tmp = [dp[i] + 1] if i >= 6**1: tmp.append(dp[i - 6**1] + 1) if i >= 9**1: tmp.append(dp[i - 9**1] + 1) if i >= 6**2: tmp.append(dp[i - 6**2] + 1) if i >= 9**2: tmp.append(dp[i - 9**2] + 1) if i >= 6**3: tmp.append(dp[i - 6**3] + 1) if i >= 9**3: tmp.append(dp[i - 9**3] + 1) if i >= 6**4: tmp.append(dp[i - 6**4] + 1) if i >= 9**4: tmp.append(dp[i - 9**4] + 1) if i >= 6**5: tmp.append(dp[i - 6**5] + 1) if i >= 9**5: tmp.append(dp[i - 9**5] + 1) if i >= 6**6: tmp.append(dp[i - 6**6] + 1) if i >= 9**6: tmp.append(dp[i - 9**6] + 1) dp[i] = min(tmp) print(dp[n])
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s643457251
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
n = int(input()) sixs = [6, 36, 216, 1296, 7776, 46656] nines = [9, 81, 729, 6561, 59049] lis = [0] + [100000 for i in range(170000)] for i in range(0, 100001): for j in sixs: if lis[i + j] > lis[i] + 1: lis[i + j] = lis[i] + 1 for j in nines: if lis[i + j] > lis[i] + 1: lis[i + j] = lis[i] + 1 print(lis[n])
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s525223395
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
n = int(input()) ans = 10**10 for a in range(5): for b in range(2): for c in range(5): for d in range(5): for e in range(5): for f in range(5): for g in range(1): for h in range(3): for i in range(7): for k in range(8): for l in range(8): for m in range(1): if ( 1 * a + 6 * b + 36 * c + 6**3 * d + 6**4 * e + 6**5 * f + 6**6 * g + 9 * h + 9**2 * i + 9**3 * k + 9**4 * l + 9**5 * m == n ): ans = min( ans, a + b + c + d + e + f + g + h + i + k + l + m, ) print(ans)
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s162833815
Accepted
p03329
Input is given from Standard Input in the following format: N
wt = int(input()) w = [1] for i in range(7): w.append(6 ** (i + 1)) for i in range(5): w.append(9 ** (i + 1)) n = len(w) dp = [[float("inf") for i in range(wt + 1)] for j in range(n + 1)] dp[0][0] = 0 for i in range(n): for j in range(wt + 1): if j >= w[i]: dp[i + 1][j] = min(dp[i + 1][j - w[i]] + 1, dp[i][j]) else: dp[i + 1][j] = dp[i][j] print(dp[n][wt])
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
If at least x operations are required to withdraw exactly N yen in total, print x. * * *
s773050251
Wrong Answer
p03329
Input is given from Standard Input in the following format: N
s = input() a = int(s) list = [] list.append(1) list.append(6) list.append(9) list.append(36) list.append(81) list.append(216) list.append(729) list.append(1296) list.append(6561) list.append(7776) list.append(46656) list.append(59049) pp = [] def money(x, y): for i in range(12): if 0 <= x // list[i] < 6: if x % list[i] == 0: pp.append(y + x // list[i]) break else: money(x - list[i], y + 1) money(a, 0) print(min(pp))
Statement To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation: * 1 yen (the currency of Japan) * 6 yen, 6^2(=36) yen, 6^3(=216) yen, ... * 9 yen, 9^2(=81) yen, 9^3(=729) yen, ... At least how many operations are required to withdraw exactly N yen in total? It is not allowed to re-deposit the money you withdrew.
[{"input": "127", "output": "4\n \n\nBy withdrawing 1 yen, 9 yen, 36(=6^2) yen and 81(=9^2) yen, we can withdraw\n127 yen in four operations.\n\n* * *"}, {"input": "3", "output": "3\n \n\nBy withdrawing 1 yen three times, we can withdraw 3 yen in three operations.\n\n* * *"}, {"input": "44852", "output": "16"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s167001633
Wrong Answer
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
from collections import defaultdict def main(): N, M = list(map(int, input().split(" "))) adj_from = defaultdict(list) adj_to = defaultdict(list) for _ in range(M): S, T = list(map(lambda x: int(x) - 1, input().split(" "))) adj_from[T].append(S) adj_to[S].append(T) # 青木君が邪魔しない場合に、各edgeがカウントされる確率を求める dp = [[0] * N for _ in range(N)] # P[s][t]: edge 's->t' がカウントされる確率 for t in adj_to[0]: dp[0][t] += 1 / len(adj_to[0]) for n in range(1, N): for t in adj_to[n]: dp[n][t] = sum([dp[f][n] for f in adj_from[n]]) / len(adj_to[n]) sum_p = sum([sum(row) for row in dp]) # 青木君が邪魔しない場合のedge数の期待値 # 青木君が邪魔した時の減少分を求める rem_p = 0 for row in dp: # 出次数が1のnodeから出るedgeを除外するとNG if len([r for r in row if r != 0]) == 1: continue for r in row: rem_p = max(rem_p, r) print(sum_p - rem_p) if __name__ == "__main__": main()
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s427604904
Accepted
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(m)] go = [[] for i in range(n + 1)] come = [[] for i in range(n + 1)] for a, b in ab: go[a].append(b) come[b].append(a) dpe = [0] * (n + 1) for i in range(1, n + 1)[::-1]: if i < n and go[i]: dpe[i] /= len(go[i]) for j in come[i]: dpe[j] += 1 + dpe[i] dpp = [0] * (n + 1) dpp[1] = 1 for i in range(1, n + 1): for j in go[i]: dpp[j] += dpp[i] / len(go[i]) ans = dpe[1] for a, b in ab: pa = dpp[a] if len(go[a]) == 1: continue ea = dpe[a] - 1 - ((dpe[a] - 1) * len(go[a]) - dpe[b]) / (len(go[a]) - 1) ans = min(ans, dpe[1] - pa * ea) print(ans)
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s709551776
Accepted
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
N, M = map(int, input().split()) st = [list(map(int, input().split())) for i in range(M)] way = [[] for i in range(N)] for s, t in st: way[s - 1].append(t - 1) dp = [0] * N dp_reducable = [0] * N pr = [0] * N pr[0] = 1 for i in range(N - 1, -1, -1): l = len(way[i]) if l > 1: MAX = 0 x = 0 for j in way[i]: x += dp[j] if dp[j] > MAX: MAX = dp[j] x_r = (x - MAX) / (l - 1) + 1 x = x / l + 1 x_r = x - x_r elif l == 0: continue else: x = dp[way[i][0]] + 1 x_r = 0 dp[i] = x dp_reducable[i] = x_r i = N - 1 - i - 1 l = len(way[i]) for j in way[i]: pr[j] += pr[i] / l print(dp[0] - max(p * r for p, r in zip(pr, dp_reducable)))
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s437621377
Runtime Error
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
n, m = map(int, input().split()) t_s = [] efflux = [] for i in range(n): t_s.append([]) efflux.append(0) for _ in range(m): si, ti = map(int, input().split()) t_s[ti - 1].append(si) efflux[si - 1] += 1 e_min = n for t_omit, ses_omit in enumerate(t_s): for s_omit in ses_omit: p = [] e = [] for t, ses in enumerate(t_s): ses2 = [x for x in ses] if t == t_omit and s_omit in ses2: ses2.remove(s_omit) p.append(sum((p[s] / efflux[s] for s in ses2))) e.append(sum((e[s] for s in ses2)) + p[t]) if e[-1] < e_min: e_min = e[-1] print(e_min)
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s817498008
Wrong Answer
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
# 这题离谱 # 这题离谱 # 这题离谱 # 这题离谱 # 这题离谱 # 这题离谱 # 这题离谱 # 这题离谱 print("不会概率DP")
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s558782159
Runtime Error
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = map(int, input().split()) m = map(int, read().split()) ST = zip(m, m) edge_out = [[] for i in range(N)] # edge_out[i]はiから出ている道 edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道 for s, t in ST: edge_out[s].append(t) edge_in[t].append(s) edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数 dp = [0.0] * (N + 1) # dp[i]はiからNへの距離の期待値 dp[N - 1] = 1.0 # 道を塞がない場合 for i in range(N - 2, 0, -1): dp[i] = 1 + sum(dp[j] for j in edge_out[i]) / edge_sum[i] p_to_i = [0] * (N + 1) # p_to_i[i]は1から各iへ到達する確率 p_to_i[1] = 1 for i in range(2, N + 1): p_to_i[i] = sum(p_to_i[j] / edge_sum[j] for j in edge_in[i]) t = 0 for i in range(1, N - 1): if edge_sum[i] == 1: continue # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ t = max( t, p_to_i[i] * ( dp[i] - 1 - ((dp[i] - 1) * edge_sum[i] - max(dp[j] for j in edge_out[i])) / (edge_sum[i] - 1) ), ) print(dp[1] - t)
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s707964758
Wrong Answer
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
import numpy as np N, M = map(int, input().strip().split()) R_table = [[False] * N for _ in range(N)] M_list = [] for _ in range(M): s, t = map(int, input().strip().split()) s -= 1 t -= 1 R_table[s][t] = True M_list.append((s, t)) # print(R_table) def make_col(col, i): count = 0 for j in range(N): if col[j]: count += 1 if count == 0: return None m_col = [] ratio = 1.0 / count for j in range(N): if col[j]: m_col.append(ratio) else: m_col.append(0.0) m_col[i] = -1.0 return m_col def make_matrix(R_table): matrix = [] for i in range(N - 1): matrix.append(make_col(R_table[i], i)) matrix.append([0.0] * (N - 1) + [1.0]) return np.array(matrix) v_one = np.array([-1.0] * (N - 1) + [0.0]) def solve(matrix): # print(matrix) # print(v_one) s = np.linalg.solve(matrix, v_one) # print(s) return s matrix = make_matrix(R_table) min_dist = solve(matrix)[0] for s, t in M_list: org_col = matrix[s] tmp_col = list(R_table[s]) tmp_col[t] = False tmp_col2 = make_col(tmp_col, s) if tmp_col2 != None: matrix[s] = np.array(tmp_col2) try: dist = solve(matrix)[0] if min_dist == None or dist < min_dist: min_dist = dist except: pass matrix[s] = org_col print(min_dist)
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s856111304
Wrong Answer
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
from collections import deque N, M = map(int, input().split()) G1, G2 = [[] for _ in range(N)], [[] for _ in range(N)] for i in range(M): a, b = map(int, input().split()) G1[a - 1].append(b - 1) G2[b - 1].append(a - 1) def bfs(G, s): seen = [0] * N d = [0] * N prev = [-1] * N todo = deque() seen[s] = 1 todo.append(s) while todo: a = todo.popleft() for b in G[a]: if seen[b] == 0: seen[b] = 1 todo.append(b) d[b] += d[a] + 1 prev[b] = a return d, prev d, prev = bfs(G2, N - 1) G3 = [{} for _ in range(N)] for i in range(N): if not G1[i]: continue MIN = min([d[j] for j in G1[i]]) nmin = sum([1 if MIN == d[j] else 0 for j in G1[i]]) for j in G1[i]: if len(G1[i]) == 1: p = 1 elif d[j] == MIN: p = 1 / (len(G1[i]) - 1) else: p = (1 - 1 / (len(G1[i]) - nmin)) * (1 / (len(G1[i]) - 1)) G3[i][j] = p inc = [len(G2[i]) for i in range(N)] def toposort(inc, out): # https://ikatakos.com/pot/programming_algorithm/graph_theory/topological_sort S = {i for i, c in enumerate(inc) if c == 0} L = [] while S: n = S.pop() L.append(n) for m in out[n]: inc[m] -= 1 if inc[m] == 0: S.add(m) return L L = toposort(inc, G1) dp = [[0] * N for _ in range(N)] dp[0][0] = 1 for v1 in L[:-1]: for v2 in G3[v1].keys(): p = G3[v1][v2] for i in range(1, N): dp[v2][i] += dp[v1][i - 1] * p ans = 0 for i in range(N): ans += i * dp[-1][i] print(ans)
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the value of E when Aoki makes a choice that minimizes E. Your output will be judged as correct when the absolute or relative error from the judge's output is at most 10^{-6}. * * *
s933214693
Wrong Answer
p02884
Input is given from Standard Input in the following format: N M s_1 t_1 : s_M t_M
n, m = map(int, input().split()) room = [[] for _ in range(n)] for i in range(m): s, t = map(int, input().split()) room[s - 1].append(t - 1) def bfs(i, count): if i == n - 1: return count ex_list = [] for j in room[i]: ex_list.append(bfs(j, count + 1)) num_root = len(ex_list) ex_list.sort() if num_root == 1: return ex_list[0] else: return sum(ex_list[:-1]) / (num_root - 1) print(bfs(0, 0))
Statement There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each room except Room N, there is at least one passage going from that room. Takahashi will escape from the cave. Each time he reaches a room (assume that he has reached Room 1 at the beginning), he will choose a passage uniformly at random from the ones going from that room and take that passage. Aoki, a friend of Takahashi's, can block one of the passages (or do nothing) before Takahashi leaves Room 1. However, it is not allowed to block a passage so that Takahashi is potentially unable to reach Room N. Let E be the expected number of passages Takahashi takes before he reaches Room N. Find the value of E when Aoki makes a choice that minimizes E.
[{"input": "4 6\n 1 4\n 2 3\n 1 3\n 1 2\n 3 4\n 2 4", "output": "1.5000000000\n \n\nIf Aoki blocks the passage from Room 1 to Room 2, Takahashi will go along the\npath `1` \u2192 `3` \u2192 `4` with probability \\frac{1}{2} and `1` \u2192 `4` with\nprobability \\frac{1}{2}. E = 1.5 here, and this is the minimum possible value\nof E.\n\n* * *"}, {"input": "3 2\n 1 2\n 2 3", "output": "2.0000000000\n \n\nBlocking any one passage makes Takahashi unable to reach Room N, so Aoki\ncannot block a passage.\n\n* * *"}, {"input": "10 33\n 3 7\n 5 10\n 8 9\n 1 10\n 4 6\n 2 5\n 1 7\n 6 10\n 1 4\n 1 3\n 8 10\n 1 5\n 2 6\n 6 9\n 5 6\n 5 8\n 3 6\n 4 8\n 2 7\n 2 9\n 6 7\n 1 2\n 5 9\n 6 8\n 9 10\n 3 9\n 7 8\n 4 5\n 2 10\n 5 7\n 3 5\n 4 7\n 4 9", "output": "3.0133333333"}]
Print the answer modulo 10^{9}+7. * * *
s935101196
Runtime Error
p03796
The input is given from Standard Input in the following format: N
sum = 1 N = int(input()) for i in range(N): sum *= (i+1) sum = sum % 1000000007 print(sum%1000000007)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s409749816
Accepted
p03796
The input is given from Standard Input in the following format: N
from statistics import mean, median, variance, stdev import numpy as np import sys import math import fractions import itertools import copy def j(q): if q == 1: print("YES") else: print("NO") exit(0) def ct(x, y): if x > y: print("GREATER") elif x < y: print("LESS") else: print("EQUAL") def ip(): return int(input()) n = ip() # 入力整数1つ # n,m= (int(i) for i in input().split()) #入力整数横2つ # w,a,b = (int(i) for i in input().split()) #入力整数横3つ # n,a,b,c= (int(i) for i in input().split()) #入力整数横4つ # a = [int(i) for i in input().split()] #入力整数配列 # a = input() #入力文字列 # a = input().split() #入力文字配列 # n = ip() #入力セット(整数改行あり)(1/2) # a=[ip() for i in range(n)] #入力セット(整数改行あり)(2/2) # a=[input() for i in range(h)] # jの変数はしようできないので注意 # 全足しにsum変数使用はsum関数使用できないので注意 s = 1 for i in range(1, n + 1): s *= i s %= pow(10, 9) + 7 print(s)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s525505680
Accepted
p03796
The input is given from Standard Input in the following format: N
MOD = 10**9 + 7 class Fp(int): def __new__(self, x=0): return super().__new__(self, x % MOD) def inv(self): return self.__class__(super().__pow__(MOD - 2, MOD)) def __add__(self, value): return self.__class__(super().__add__(value)) def __sub__(self, value): return self.__class__(super().__sub__(value)) def __mul__(self, value): return self.__class__(super().__mul__(value)) def __floordiv__(self, value): return self.__class__(self * self.__class__(value).inv()) def __pow__(self, value): return self.__class__(super().__pow__(value % (MOD - 1), MOD)) __radd__ = __add__ __rmul__ = __mul__ def __rsub__(self, value): return self.__class__(-super().__sub__(value)) def __rfloordiv__(self, value): return self.__class__(self.inv() * value) def __iadd__(self, value): self = self + value return self def __isub__(self, value): self = self - value return self def __imul__(self, value): self = self * value return self def __ifloordiv__(self, value): self = self // value return self def __ipow__(self, value): self = self**value return self def __neg__(self): return self.__class__(super().__neg__()) N = int(input()) ans = Fp(1) for i in range(1, N + 1): ans *= i print(ans)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s173521578
Accepted
p03796
The input is given from Standard Input in the following format: N
N = int(input()) class Mint: MOD = 10**9 + 7 def __init__(self, x=0): self.x = (x % self.MOD + self.MOD) % self.MOD def __iadd__(self, other): self.x += other.x if self.x >= self.MOD: self.x -= self.MOD return self def __isub__(self, other): self.x += self.MOD - other.x if self.x >= self.MOD: self.x -= self.MOD return self def __imul__(self, other): self.x *= other.x self.x %= self.MOD return self def __add__(self, other): ans = Mint(self.x) ans += other return ans def __sub__(self, other): ans = Mint(self.x) ans -= other return ans def __mul__(self, other): ans = Mint(self.x) ans *= other return ans def __pow__(self, n): if n == 0: return Mint(1) a = self.__pow__(n >> 1) a *= a if n & 1: a *= self return a def inv(self): return self ** (self.MOD - 2) def __ifloordiv__(self, other): self *= other.inv() return self def __floordiv__(self, other): ans = Mint(self.x) ans //= other return ans def Main(N): ans = Mint(1) for i in range(1, N + 1): ans *= Mint(i) return ans.x print(Main(N))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s213325611
Runtime Error
p03796
The input is given from Standard Input in the following format: N
import math N = int(input()) print(factorial.(N)%(10**9+7))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s874645968
Runtime Error
p03796
The input is given from Standard Input in the following format: N
n = int(input()) power = 1 for i in range(1,n+1): power *= i power = power % (10 ** 9 + 7)) print(power % (10 ** 9 + 7))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s240448318
Runtime Error
p03796
The input is given from Standard Input in the following format: N
from math import factorial N=int(input()) print(factorial(N)%(7+1e9)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s485499575
Runtime Error
p03796
The input is given from Standard Input in the following format: N
import math print(math.factorial(int(input())%10**9+7)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s747923585
Runtime Error
p03796
The input is given from Standard Input in the following format: N
import math N = int(input()) print((math.factorial(N)/(10**9 + 7))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s118350059
Runtime Error
p03796
The input is given from Standard Input in the following format: N
import math N = int(input()) print(math.factorial(N)%(10**9+7)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s177181368
Runtime Error
p03796
The input is given from Standard Input in the following format: N
n=int(input()) ans=int(1) for i in range(1,n+1): ans*=i ans%=1000000007 print(ans)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s389882551
Runtime Error
p03796
The input is given from Standard Input in the following format: N
N = int(input()) P = 1 for n in range(1,N + 1): P = P * n print(P %% ((10**9) + 7))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s556333893
Runtime Error
p03796
The input is given from Standard Input in the following format: N
N = int(input()) ans = 1 for i in range(N) ans = ans * (i + 1) % (10**9 + 7) print(ans)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s156250100
Runtime Error
p03796
The input is given from Standard Input in the following format: N
N = int(input()) ans = 1 for i in range(1, N+1): (ans *= i) %= 1000000007 print(ans)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s235149656
Runtime Error
p03796
The input is given from Standard Input in the following format: N
n = int(input()) p=1 for i in range(1, n+1): p = p*i print(p % (10**9 + 7)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s458655299
Accepted
p03796
The input is given from Standard Input in the following format: N
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa = lambda: list(map(float, stdin.readline().split())) nfan = lambda y: [nfa() for _ in range(y)] ns = lambda: stdin.readline().rstrip() nsn = lambda y: [ns() for _ in range(y)] ncl = lambda y: [list(ns()) for _ in range(y)] nas = lambda: stdin.readline().split() n = ni() ans = 1 for i in range(1, n + 1): ans = ans * i % mod print(ans % mod)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s343520280
Runtime Error
p03796
The input is given from Standard Input in the following format: N
w, a, b = map(int, input().split()) if b >= a + w: print(b - a - w) elif b + w <= a: print(a - b - w) else: print(0)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s388152982
Runtime Error
p03796
The input is given from Standard Input in the following format: N
def imp_kai(n): ac = 1 for i in range(n): ac *= i + 1 ac = ac % (1e9 + 7) return ac % (1e9 + 7) - n = int(input()) print(imp_kai(n))
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s860951988
Runtime Error
p03796
The input is given from Standard Input in the following format: N
s = input().split() h = int(s[0]) w = int(s[1]) s = [] for i in range(h): s.append(input()) for i in range(h): row = "" for j in range(w): cnt = 0 if s[i][j] == "#": row += "#" continue if i > 0 and j > 0 and s[i - 1][j - 1] == "#": cnt += 1 if i > 0 and s[i - 1][j] == "#": cnt += 1 if i > 0 and j < w - 1 and s[i - 1][j + 1] == "#": cnt += 1 if j > 0 and s[i][j - 1] == "#": cnt += 1 if j < w - 1 and s[i][j + 1] == "#": cnt += 1 if i < h - 1 and s[i + 1][j - 1] == "#": cnt += 1 if i < h - 1 and s[i + 1][j] == "#": cnt += 1 if i < h - 1 and j < w - 1 and s[i + 1][j + 1] == "#": cnt += 1 row += str(cnt) print(row)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s761055319
Runtime Error
p03796
The input is given from Standard Input in the following format: N
n = int(input()) power = 1 for i in range(n): power = power + (i+1)%1000000007 power %= %1000000007 print(power)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s845637349
Runtime Error
p03796
The input is given from Standard Input in the following format: N
n, m = map(int, input().split()) if 2 * n >= m: print(m // 2) else: a = m - 2 * n b = a // 4 print(n + b)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s677016338
Wrong Answer
p03796
The input is given from Standard Input in the following format: N
print(int(input()) % 1000000007)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s044540019
Accepted
p03796
The input is given from Standard Input in the following format: N
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! # 標準エラー出力 def printargs2err(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} print( ", ".join(names.get(id(arg), "???") + " : " + repr(arg) for arg in args), file=sys.stderr, ) def debug(*args): print(*args, file=sys.stderr) def printglobals(): for symbol, value in globals().items(): print('symbol="%s"、value=%s' % (symbol, value), file=sys.stderr) def printlocals(): for symbol, value in locals().items(): print('symbol="%s"、value=%s' % (symbol, value), file=sys.stderr) # 入力(後でいじる) def pin(type=int): return map(type, input().split()) # input def resolve(): (N,) = pin() ans = 1 mod = 7 + (pow(10, 9)) for i in range(1, N + 1): ans *= i ans %= mod print(ans) # print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM]) # if __name__=="__main__":resolve() """ #printデバッグ消した? #前の問題の結果見てないのに次の問題に行くの? """ """ お前カッコ閉じるの忘れてるだろ """ 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 = """3""" output = """6""" self.assertIO(input, output) def test_入力例_2(self): input = """10""" output = """3628800""" self.assertIO(input, output) def test_入力例_3(self): input = """100000""" output = """457992974""" self.assertIO(input, output) if __name__ == "__main__": resolve()
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s574012963
Accepted
p03796
The input is given from Standard Input in the following format: N
# #    ⋀_⋀ #    (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline from math import floor, ceil, sqrt, factorial, log # log2ないyp from heapq import heappop, heappush, heappushpop from collections import Counter, defaultdict, deque from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from copy import deepcopy inf = float("inf") mod = 10**9 + 7 def pprint(*A): for a in A: print(*a, sep="\n") def INT_(n): return int(n) - 1 def MI(): return map(int, input().split()) def MF(): return map(float, input().split()) def MI_(): return map(INT_, input().split()) def LI(): return list(MI()) def LI_(): return [int(x) - 1 for x in input().split()] def LF(): return list(MF()) def LIN(n: int): return [I() for _ in range(n)] def LLIN(n: int): return [LI() for _ in range(n)] def LLIN_(n: int): return [LI_() for _ in range(n)] def LLI(): return [list(map(int, l.split())) for l in input()] def I(): return int(input()) def F(): return float(input()) def ST(): return input().replace("\n", "") def main(): print(factorial(int(input())) % mod) if __name__ == "__main__": main()
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s362761730
Accepted
p03796
The input is given from Standard Input in the following format: N
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x) - 1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 # A def A(): n = II() ans = n * 800 print(ans - (n // 15) * 200) return # B def B(): n = II() print(math.factorial(n) % mod) return # C def C(): return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": B()
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
Print the answer modulo 10^{9}+7. * * *
s726623831
Accepted
p03796
The input is given from Standard Input in the following format: N
n = int(input()) if n < 5000: power = 1 index = 2 while index < n + 1: power *= index index += 1 elif n == 5000: power = 541108809 + (10**9 + 7) * 2 elif n > 5000 and n < 40000: power = 541108809 index = 5001 while index < n + 1: power *= index index += 1 elif n == 40000: power = 422550956 + (10**9 + 7) * 2 elif n > 40000 and n < 70000: power = 422550956 index = 40001 while index < n + 1: power *= index index += 1 elif n == 70000: power = 296716438 + (10**9 + 7) * 2 else: power = 296716438 index = 70001 while index < n + 1: power *= index index += 1 if power > 10**9 + 7: print(power % (10**9 + 7)) else: print(power)
Statement Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
[{"input": "3", "output": "6\n \n\n * After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1.\n * After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2.\n * After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.\n\n* * *"}, {"input": "10", "output": "3628800\n \n\n* * *"}, {"input": "100000", "output": "457992974\n \n\nPrint the answer modulo 10^{9}+7."}]
For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.
s288264777
Wrong Answer
p00010
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers.
def main(): import math while True: try: for i in range(int(input())): x1, y1, x2, y2, x3, y3 = map(float, input().split()) a = y1 - y2 b = y1 - y3 if a == 0: x = (x1 + x2) / 2 c = (x3 - x1) / (y1 - y3) d = (-x1 - x3) / 2 + (y1 + y3) / 2 y = c * x + d elif b == 0: x = (x1 + x3) / 2 c = (x2 - x1) / (y1 - y2) d = (-x1 - x3) / 2 + (y1 + y3) / 2 y = c * x + d else: a = (x2 - x1) / (y1 - y2) b = (-x1 - x2) / 2 + (y1 + y2) / 2 c = (x3 - x1) / (y1 - y3) d = (-x1 - x3) / 2 + (y1 + y3) / 2 x = (d - b) / (a - c) y = a * x + b r = math.sqrt((x - x1) ** 2 + (y - y1) ** 2) print("{0:.3f} {1:.3f} {2:.3f}".format(x, y, r)) except: break
Circumscribed Circle of A Triangle. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
[{"input": "0.0 0.0 2.0 0.0 2.0 2.0", "output": ".000 1.000 1.414"}]
For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.
s167038521
Accepted
p00010
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers.
p = int(input()) for i in range(p): x1, y1, x2, y2, x3, y3 = map(float, input().split(" ")) xa, ya, xb, yb = x2 - x1, y2 - y1, x3 - x1, y3 - y1 a = complex(xa, ya) b = complex(xb, yb) z0 = abs(a) ** 2 * b - abs(b) ** 2 * a z0 /= a.conjugate() * b - a * b.conjugate() z = z0 + complex(x1, y1) zx = "{0:.3f}".format(z.real) zy = "{0:.3f}".format(z.imag) r = "{0:.3f}".format(abs(z0)) print(zx, zy, r)
Circumscribed Circle of A Triangle. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
[{"input": "0.0 0.0 2.0 0.0 2.0 2.0", "output": ".000 1.000 1.414"}]
For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.
s260481070
Wrong Answer
p00010
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers.
import sys f = sys.stdin def take2(iterable): while True: yield next(iterable), next(iterable) # 外積 def cross(v1, v2): return v1.real * v2.imag - v1.imag * v2.real # 線分13と線分24の交点を求める def get_intersection(p1, p2, p3, p4): a1 = p4 - p2 b1 = p2 - p3 b2 = p1 - p2 s1 = cross(a1, b2) / 2 s2 = cross(a1, b1) / 2 print(s1, s2) return p1 + (p3 - p1) * s1 / (s1 + s2) n = int(f.readline()) for i in range(n): p1, p2, p3 = [x + y * 1j for x, y in take2(map(float, f.readline().split()))] p12 = (p1 + p2) / 2 p13 = (p1 + p3) / 2 pxy = get_intersection(p12, p13, p12 + (p2 - p1) * 1j, p13 + (p1 - p3) * 1j) r = abs(pxy - p1) print("{:.3f} {:.3f} {:.3f}".format(pxy.real, pxy.imag, r))
Circumscribed Circle of A Triangle. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
[{"input": "0.0 0.0 2.0 0.0 2.0 2.0", "output": ".000 1.000 1.414"}]
For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.
s794785392
Accepted
p00010
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers.
for _ in range(int(input())): x1, y1, x2, y2, x3, y3 = map(float, input().split()) d = 2 * (x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3 + x1 * y2 - x2 * y1) px = ( (y2 - y3) * (x1**2 + y1**2) + (y3 - y1) * (x2**2 + y2**2) + (y1 - y2) * (x3**2 + y3**2) ) / d py = ( -1 * ( (x2 - x3) * (x1**2 + y1**2) + (x3 - x1) * (x2**2 + y2**2) + (x1 - x2) * (x3**2 + y3**2) ) / d ) print( "{0:.3f} {1:.3f} {2:.3f}".format( px, py, ((x1 - px) ** 2 + (y1 - py) ** 2) ** 0.5 ) )
Circumscribed Circle of A Triangle. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
[{"input": "0.0 0.0 2.0 0.0 2.0 2.0", "output": ".000 1.000 1.414"}]
For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.
s768014470
Accepted
p00010
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of: $x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ in a line. All the input are real numbers.
from math import acos from math import sin def ang(ax, ay, ox, oy, bx, by): oax, oay = ax - ox, ay - oy obx, oby = bx - ox, by - oy r1, r2 = oax**2 + oay**2, obx**2 + oby**2 return acos((oax * obx + oay * oby) / (r1 * r2) ** 0.5) def circumcircle(x1, y1, x2, y2, x3, y3): s2A = sin(2 * ang(x3, y3, x1, y1, x2, y2)) s2B = sin(2 * ang(x1, y1, x2, y2, x3, y3)) s2C = sin(2 * ang(x2, y2, x3, y3, x1, y1)) px = (s2A * x1 + s2B * x2 + s2C * x3) / (s2A + s2B + s2C) + 0.0 py = (s2A * y1 + s2B * y2 + s2C * y3) / (s2A + s2B + s2C) + 0.0 r = (((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5) / ( 2 * sin(ang(x2, y2, x1, y1, x3, y3)) ) + 0.0 return px, py, r n = int(input()) for i in range(n): print( "{0[0]:.3f} {0[1]:.3f} {0[2]:.3f}".format( circumcircle(*tuple(map(float, input().split()))) ) )
Circumscribed Circle of A Triangle. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
[{"input": "0.0 0.0 2.0 0.0 2.0 2.0", "output": ".000 1.000 1.414"}]
Print the area of the triangle ABC. * * *
s316007658
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
X, Y, Z = map(int, input().split()) print(X * Y // 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s560222075
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a, b, c = map(int, input().split()) print(a*b / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s890271965
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
list1 = list(map(int, input().split())) list1.sort() print(int(list1[0] * list1[1] / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s731053259
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
edges = list(map(int, input().split())) edges.sort() print(edges[0] * edges[1] // 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s349157182
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
# abc116_a.py # https://atcoder.jp/contests/abc116/tasks/abc116_a # A - Right Triangle / # 実行時間制限: 2 sec / メモリ制限: 1024 MB # 配点 : 100点 # 問題文 # 直角三角形 ABCがあります。∠ABC=90°です。 # 三角形 ABCの三辺の長さである |AB|,|BC|,|CA| が与えられるので、直角三角形 ABCの面積を求めて下さい。 # ただし、三角形 ABCの面積は整数となることが保証されています。 # 制約 # 1≦|AB|,|BC|,|CA|≦100 # 入力はすべて整数である。 # 三角形 ABCの面積は整数である。 # 入力 # 入力は以下の形式で標準入力から与えられます。 # |AB| |BC| |CA| # 出力 # 三角形 ABCの面積を出力してください。 # 入力例 1 # 3 4 5 # 出力例 1 # 6 # tri # この三角形の面積は 6です。 # 入力例 2 # 5 12 13 # 出力例 2 # 30 # この三角形の面積は 30です。 # 入力例 3 # 45 28 53 # 出力例 3 # 630 # この三角形の面積は 630です。 def calculation(lines): # X = lines[0] # N = int(lines[0]) ab, bc, ca = list(map(int, lines[0].split())) # values = list() # for i in range(N): # values.append(int(lines[i+1])) result = int(ab * bc / 2) return [result] # 引数を取得 def get_input_lines(lines_count): lines = list() for _ in range(lines_count): lines.append(input()) return lines # テストデータ def get_testdata(pattern): if pattern == 1: lines_input = ["3 4 5"] lines_export = [6] if pattern == 2: lines_input = ["5 12 13"] lines_export = [30] if pattern == 3: lines_input = ["45 28 53"] lines_export = [630] return lines_input, lines_export # 動作モード判別 def get_mode(): import sys args = sys.argv if len(args) == 1: mode = 0 else: mode = int(args[1]) return mode # 主処理 def main(): import time started = time.time() mode = get_mode() if mode == 0: lines_input = get_input_lines(1) else: lines_input, lines_export = get_testdata(mode) lines_result = calculation(lines_input) for line_result in lines_result: print(line_result) # if mode > 0: # print(f'lines_input=[{lines_input}]') # print(f'lines_export=[{lines_export}]') # print(f'lines_result=[{lines_result}]') # if lines_result == lines_export: # print('OK') # else: # print('NG') # finished = time.time() # duration = finished - started # print(f'duration=[{duration}]') # 起動処理 if __name__ == "__main__": main()
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s035493546
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): a, b, c = li_input() print(a * b // 2) main()
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s014404642
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
edges = sorted(list(map(int, input().split()))) print(int(edges[0] * edges[1] * 0.5))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s480576611
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b # aとbの最大公約数 def gcd(a, b): if b == 0: return a return gcd(b, a % b) # aとbの最小公倍数 def lcm(a, b): g = gcd(a, b) return a / g * b def main(): AB, BC, CA = map(int, input().split()) print(AB * BC // 2) if __name__ == "__main__": main()
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s294073485
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
n = int(input()) Hs = list(map(int, input().split())) f = [0 for _ in range(n)] r = 1 c = 0 while r != n: r = 1 for i in range(n): if f[i] < Hs[i]: if r > 0: c += 1 r = 0 f[i] += 1 else: r += 1 r -= 1 print(c)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s464559589
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
AB, BC, CA = map(int, input().split()) if (1 <= AB & AB <= 100) & (1 <= BC & BC <= 100) & (1 <= CA & CA <= 100) S = int(AB * BC / 2) print(S)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s879787789
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a, b, c = [int(i) for i in input().split()] if a >= b and a >= c: print(c*b//2) else if b >= c and b >= a: print(a*c//2) else: print(a*b//2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s465822001
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
if __name__ == "__main__": import sys input = sys.stdin.readline import collections n, k = map(int, input().split()) td = [list(map(int, input().split())) for _ in range(n)] td.sort(key=lambda x: x[1], reverse=True) ans_list = [0] reverse_td = list(zip(*td)) c = collections.Counter(reverse_td[0][:k]) kind = len(c) ans = sum(reverse_td[1][:k]) + kind**2 check = k - 1 flag = False for i in range(k, n): t = td[i][0] d = td[i][1] if t in c: pass else: c[t] = 1 while True: new_t = td[check][0] if c[new_t] == 1: check -= 1 if check == -1: flag = True break else: c[new_t] -= 1 ans_list.append(2 * kind + 1 + d - td[check][1]) kind += 1 if flag: break print(ans + max(ans_list))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s058349656
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a, b, c = [int(i) for i in input().split()] if a >= b and a >= c: print(c*b//2) else if b >= c and b >= a: print(a*c//2) else print(a*b//2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s218984187
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
import math # inputList=[] # for i in range(6): # inputNum = input() # inputList.append(inputNum) inputa = input().split() # inputb = input().split() a = int(inputa[0]) b = int(inputa[1]) c = int(inputa[2]) # x = int(inputb[0]) # y = int(inputb[1]) print(float(a) * float(b) / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s405210293
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
s = int(input()) s = max(min(s, 100), 1) f = lambda x: x * 0.5 if x % 2 == 0 else 3 * x + 1 array = [s] while s != 1: s = f(int(s)) array.append(s) array.append(4) freq = len(array) idx = 0 for n, i in enumerate(array): for j in array[n:]: if s == j: idx = n + 2 break print(idx)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s651148813
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
# coding:utf-8 import copy N, K = map(int, input().split()) T = [] D = [] ls_td = [] for n in range(N): t, d = map(int, input().split()) ls_td.append([t, d]) ls_td = sorted(ls_td, key=lambda x: x[1])[::-1] head = ls_td[:K] tail = ls_td[K:] def get_set(mat): st = set() for t, d in mat: st.add(t) return st def score(mat): r = 0 ls_t = set() for t, d in mat: ls_t.add(t) r += d r += len(ls_t) ** 2 return r def search_del(mat): idx = -1 st = set() for i, (t, d) in enumerate(mat): if t in st: idx = i st.add(t) return idx st = get_set(head) current_score = score(head) idx = search_del(head) for t, d in tail: if idx == -1: break if t in st: pass else: new = copy.deepcopy(head) new[idx] = t, d candidate_score = score(new) if current_score < candidate_score: head = new st.add(t) current_score = candidate_score idx = search_del(head) print(current_score)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s315040882
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
print((lambda l: l[0] * l[1] // 2)(sorted(list(map(int, input().split())))))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s027551806
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
x, y, z = sorted(map(int, input().split())) print((x * y) // 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s826861032
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
ary = input().split(" ") print(int(int(ary[0]) * int(ary[1]) / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s807686749
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
target = input(" ") print(int(target[0]) * int(target[1]) / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s861083084
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a = [input() for i in range(3)] print(a[0]*a[1]/2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s999725117
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a, b c = map(int, input().split()) print(a*b // 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s536790758
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
C, A, B = map(float, input().split()) print((1 / 2) * C * A)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s873321422
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
s = input().split(" ") item = [int(i) for i in s] item.sort() print(int(item[0] * item[1] / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s570148838
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
i = list(map(int, input().split())) # i_1 i_2を取得し、iに値を入れる print((i[0] * i[1]) / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s113815148
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
X = list(map(int, input().split())) X.sort() print(0.5*(X[0]*X[1])
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s198480463
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a = map(input(), split(), int()) b.remove(max(b)) print(b[0] * b[1])
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s902826113
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a = list(map(int,input().split()) a = sorted(a) print(a[0]*a[1]/2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s250597732
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
N, K, M = map(int, input().split()) print(N * K / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s568957432
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
length = list(map(int, input().split())) print(int(length[0] * length[1] / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s894956890
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
def decrease_height_by_one(hs): highest_indexes = [i for i, h in enumerate(hs) if h == max(hs)] is_indexes_discontinuous = ( i1 + 1 < i2 for i1, i2 in zip(highest_indexes, highest_indexes[1:]) ) for index in highest_indexes: hs[index] -= 1 return 1 + sum(is_indexes_discontinuous) input() hs = list(map(int, input().split())) n = 0 while max(hs): n += decrease_height_by_one(hs) print(n)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s911162781
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
n = int(input()) h = list(map(int, input().split())) sum = 0 for i in range(max(h)): if 0 not in h: h = [i - 1 if i > 0 else 0 for i in h] sum += 1 # print(h,1) else: count0 = [i for i, j in enumerate(h) if j == 0] a = count0.copy() # copy()をつけないとaを変えるとcount0も変わる b = count0.copy() a.pop(0) b.pop(-1) c = [x - y for (x, y) in zip(a, b)] # a-bが要素のリストを作る sum = sum + len(c) - c.count(1) # print(count0) if count0[0] > 0 and count0[-1] < n - 1: sum += 2 # print(1) elif count0[0] > 0 or count0[-1] < n - 1: sum += 1 # print(2) else: sum += 0 h = [i - 1 if i > 0 else 0 for i in h] # print(h,2) print(sum)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s322354228
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
nums = list(map(int, input().split())) nums.sort() print((nums[0] * nums[1]) / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s170807048
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
def takeSecond(elem): return elem[1] n, k = map(int, input().split()) sushi = [list(map(int, input().split())) for i in range(n)] sushi.sort(key=takeSecond, reverse=True) selected = sushi[:k] kindset = set([item[0] for item in selected]) startKindNum = len(kindset) score = startKindNum * startKindNum + sum([item[1] for item in selected]) maxscore = score front_pointer = k - 1 pointer = k for i in range(startKindNum + 1, min([k + 1, n + 1])): # remove the smallest one that does not decrease kind for p in range(front_pointer, -1, -1): item = selected[p] flag = False for idx in range(p): if selected[idx][0] == item[0]: score -= item[1] selected.remove(item) front_pointer = p - 1 flag = True break if flag: break # add the largest one that add kind for j in range(pointer, n): if sushi[j][0] not in kindset: selected.append(sushi[j]) kindset.add(sushi[j][0]) k += 1 pointer = j + 1 score += 2 * startKindNum + 1 + sushi[j][1] if score > maxscore: maxscore = score startKindNum += 1 break print(maxscore)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s880649625
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
n1, n2, n3 = list(map(int, input().split())) print(int(n1 * n2 / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s873761268
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
l = [int(i) for i in input().split(" ")] print(int((l[0] * l[1]) / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s293420484
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a,b,c=map(int, input().split()) print('{:.0f}'.format(a*b/2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s807908737
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
3 4 5
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s025407418
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a, c = map(int, input().split()) print(a * c * 1 / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s767635302
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
l, n, m = map(int, input().split()) print(l * m / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s854683426
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
print(int(|AB|)*int(|BC|)%2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s816253460
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a,b,c=map(int,(input().split()) print(a*b//2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s863624066
Wrong Answer
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
AB, BC, AC = map(int, input().split()) print(AB * AC / 2)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s814351018
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
d = sorted([i for i in map(int, input().split())]) print(int(d[0] * d[1] / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s567981972
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
ABC = list(map(int, input().split())) ABC.sort() print("{:.0f}".format(ABC[0] * ABC[1] / 2))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s431366069
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
A, B, C = [int(x) for x in input().split()] ans = [(A * B) // 2, (A * C) // 2, (B * C) // 2] print(min(ans))
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s109293955
Accepted
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
LL = list(map(int, input().split())) LL.sort() R = LL[0] * LL[1] // 2 print(R)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s398883087
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
a,b,c = map(int, input().strip().split(’ ’)) area = a*c print("%d" % area)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]
Print the area of the triangle ABC. * * *
s106423112
Runtime Error
p03145
Input is given from Standard Input in the following format: |AB| |BC| |CA|
よこ,たて,_ = map(int, input().split()) こたえ = よこ * たて // 2 print(こたえ)
Statement There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
[{"input": "3 4 5", "output": "6\n \n\n![tri](https://img.atcoder.jp/ghi/44c1d4cbdf4677ce3b08ca70b5ce98ea.png)\n\nThis triangle has an area of 6.\n\n* * *"}, {"input": "5 12 13", "output": "30\n \n\nThis triangle has an area of 30.\n\n* * *"}, {"input": "45 28 53", "output": "630\n \n\nThis triangle has an area of 630."}]