output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the output result of the above program for given integer n.
s723485630
Accepted
p02406
An integer n is given in a line.
print('',*[x for x in range(3,int(input())+1) if x % 3 == 0 or '3' in str(x)])
Structured Programming In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
[{"input": "", "output": "6 9 12 13 15 18 21 23 24 27 30\n \n\nPut a single space character before each element."}]
Print the output result of the above program for given integer n.
s069156721
Wrong Answer
p02406
An integer n is given in a line.
Max = int(input()) print(" ".join((str(x) for x in range(1, Max + 1) if x % 3 == 0)))
Structured Programming In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
[{"input": "", "output": "6 9 12 13 15 18 21 23 24 27 30\n \n\nPut a single space character before each element."}]
Print the output result of the above program for given integer n.
s982428385
Wrong Answer
p02406
An integer n is given in a line.
print(*[i for i in range(1, int(input())) if i % 3 == 0 or "3" in str(i)])
Structured Programming In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
[{"input": "", "output": "6 9 12 13 15 18 21 23 24 27 30\n \n\nPut a single space character before each element."}]
Print the output result of the above program for given integer n.
s527507658
Accepted
p02406
An integer n is given in a line.
n = int(input()) for _ in range(3, n + 1): flag = False if _ % 3 == 0: print(" ", _, end="", sep="") flag = True for i in list(str(_)): if i == "3" and flag == False: print(" ", _, end="", sep="") break print()
Structured Programming In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
[{"input": "", "output": "6 9 12 13 15 18 21 23 24 27 30\n \n\nPut a single space character before each element."}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s735347214
Runtime Error
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
N, A, B = map(int, input().split()) src = [int(input()) for i in range(N)] def enough(n): bomb = 0 for h in src: if h <= B*n: continue h -= B*n bomb -= (h+1)//(A-B) + 1 if bomb > n: return False return True #ok/ng: 中点が十分かどうか ng = 0 ok = 10**9 while ok - ng > 1: m = (ok+ng) // 2 if enough(m): ok = m else: ng = m print(ok)
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s481633084
Runtime Error
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
n , a, b = map(int,input().split()) teki = [] ans = 0 for i in range(n): teki.append(int(input()) tekis = list(sorted(teki)) while len(tekis) > 0: tekis[-1] = tekis[-1] - a if len(tekis) >= 2: for i in range(len(tekis) -1): tekis[i] = tekis[i] - b tekis = list(sorted(tekis)) for i in range(len(tekis)): if tekis[i] <= 0: tekis[i] = 0 while 0 in tekis: tekis.remove(0) ans += 1 print(ans)
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s907016279
Accepted
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
import bisect from math import ceil def can_exterminate(attack_count): sum_b = b * attack_count i = bisect.bisect(enemies, sum_b) for enemy in enemies[i:]: attack_count -= ceil((enemy - sum_b) / d) if attack_count < 0: return False return True def binary_search(max_attack_count): l, r, m = 1, max_attack_count + 1, 0 while l < r: m = (l + r) // 2 if can_exterminate(m): r = m else: l = m + 1 return l n, a, b = map(int, input().split()) d = a - b enemies = sorted(int(input()) for _ in range(n)) boss = max(enemies) print(binary_search(ceil(boss / b)))
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s882130879
Accepted
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
A, B, C = list(map(int, input().split())) import sys listA = " ".join(sys.stdin.readlines()).replace("\n", "").split() listA = list(map(int, listA)) m_n = 0 N = 0 B = B - C max_n = 10**10 while max_n - m_n > 1: N = 0 mid = (m_n + max_n) // 2 for i in listA: N += (max(i - C * mid, 0) - 1) // B + 1 if N <= mid: max_n = mid else: m_n = mid print(max_n)
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s854900489
Accepted
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
def solve(): N, A, B = map(int, input().split()) h = [] for _ in range(N): h.append(int(input())) ans_min = 0 ans_max = 10**9 while ans_min + 1 < ans_max: ans = (ans_min + ans_max) // 2 count = 0 for i in h: count += (max(0, i - B * ans) + A - B - 1) // (A - B) if count > ans: ans_min = ans else: ans_max = ans print(ans_max) return solve()
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the minimum number of explosions that needs to be caused in order to vanish all the monsters. * * *
s493661681
Wrong Answer
p03702
Input is given from Standard Input in the following format: N A B h_1 h_2 : h_N
(N, A, B) = [int(x) for x in input().split(" ")] hs = [int(input()) for x in range(N)] num = 0 ds = A - B while hs[-1] > 0: hs.sort() for i in range(len(hs)): hs[i] -= B hs[-1] -= ds num += 1 print(num)
Statement You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
[{"input": "4 5 3\n 8\n 7\n 4\n 2", "output": "2\n \n\nYou can vanish all the monsters in two explosion, as follows:\n\n * First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.\n * Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.\n\n* * *"}, {"input": "2 10 4\n 20\n 20", "output": "4\n \n\nYou need to cause two explosions centered at each monster, for a total of\nfour.\n\n* * *"}, {"input": "5 2 1\n 900000000\n 900000000\n 1000000000\n 1000000000\n 1000000000", "output": "800000000"}]
Print the largest perfect power that is at most X. * * *
s073965644
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
from fractions import gcd # from datetime import date, timedelta # from heapq import * import heapq import math from collections import defaultdict, Counter, deque from bisect import * import itertools import fractions import sys sys.setrecursionlimit(10**7) MOD = 10**9 + 7 # input = sys.stdin.readline def lcm(a, b): return a * b / fractions.gcd(a, b) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort() return divisors def factorize(n): fct = [] # prime factor b, e = 2, 0 # base, exponent while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append((b, e)) b, e = b + 1, 0 if n > 1: fct.append((n, 1)) return fct def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if is_prime[i]] def modpow(a, n, mod): res = 1 while n > 0: if n & 1: res = res * a % mod a = a * a % mod n >>= 1 return res def modinv(a, mod): return modpow(a, mod - 2, mod) def cnk(a, b): MOD = 10**9 + 7 ret = 1 for i in range(b): ret *= a - i ret %= MOD ret = ret * modinv(i + 1, MOD) % MOD return ret def main(): x = int(input()) v = 1 for i in range(1, 10000): if x <= i * i: print((i - 1) * (i - 1)) exit() if __name__ == "__main__": main()
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s579894449
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
#!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(): a, b, c, d = LI() x = abs(a - b) y = abs(b - c) z = abs(a - c) if (x <= d and y <= d) or z <= d: print("Yes") else: print("No") return # B def B(): X = II() x = [False] * (10**3 + 1) x[1] = True for i in range(2, int(10**1.5) + 1): x[i] = True for k in range(2, 10**3 // i + 1): x[i * k] = True for i in range(X, -1, -1): if x[i]: print(i) return return # C def C(): s = stdin.readline().rstrip() K = II() - 1 ans = [] for i in range(len(s)): for k in range(K + 1): b = s[i : i + k + 1] ans.append(b) ans = list(set(ans)) ans.sort() print(ans[K]) return # D def D(): n, m = LI() p = LI_() xy = LIR_(m) size = [1 for _ in range(n)] height = [1 for _ in range(n)] par = [i for i in range(n)] def find(x): if par[x] == x: return x else: par[x] = find(par[x]) return par[x] def union(x, y): s1 = find(x) s2 = find(y) if s1 != s2: if height[s1] < height[s2]: par[s1] = s2 size[s2] += size[s1] size[s1] = 0 else: par[s2] = s1 size[s1] += size[s2] size[s2] = 0 if height[s1] == height[s2]: height[s1] += 1 for x, y in xy: union(x, y) ans = 0 for i in range(n): if find(p[i]) == find(i): ans += 1 print(ans) return # Solve if __name__ == "__main__": B()
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s216959911
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def inputI(): return int(input().strip()) def inputS(): return input().strip() def inputIL(): return list(map(int, input().split())) def inputSL(): return list(map(str, input().split())) def inputILs(n): return list(int(input()) for _ in range(n)) def inputSLs(n): return list(input().strip() for _ in range(n)) def inputILL(n): return [list(map(int, input().split())) for _ in range(n)] def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def Yes(): print("Yes") return def No(): print("No") return #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def Base_10_to_n(X, n): if int(X / n): return Base_10_to_n(int(X / n), n) + [X % n] return [X % n] ############# # Main Code # ############# N = inputI() if N == 1: print(1) exit() M = 0 for i in range(2, N + 1): if len(factorization(i)) == 1 and factorization(i)[0][1] != 1: M = i print(M)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s755743697
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
X = int(input().strip()) tmp = 1 endflag = 10000 for j in range(2, X): for i in range(1, X): if i**j > X and tmp < (i - 1) ** j and (i - 1) ** j < X: tmp = (i - 1) ** j endflag = i break elif i >= endflag: break print(tmp)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s876034943
Accepted
p03352
Input is given from Standard Input in the following format: X
s = [x**i for x in range(1, 101) for i in range(2, 101)] a = set(s) x = int(input()) for u in range(x, 0, -1): if u in a: print(u) exit(0)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s265099447
Runtime Error
p03352
Input is given from Standard Input in the following format: X
A=int(input()) B=[1]*9 for i in range(1:10): for j in range(A+1): if j**i <= A: B[i]= j**i else:break print(B.sort()[-1])
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s166246860
Runtime Error
p03352
Input is given from Standard Input in the following format: X
A=int(input()) B=[1]*8 for i in range(2:10): for j in range(A+1): if j**i <= A: B[i-2]= j**i else:break print(B.sort()[-1])
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s730648299
Runtime Error
p03352
Input is given from Standard Input in the following format: X
x = int(input()) if x <= 3: print(1): else: a = [] for i in range(2, x + 1): j = 2 while i ** j < x: a.append(i ** j) print(max(a))
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s798971124
Accepted
p03352
Input is given from Standard Input in the following format: X
############################################################################### from sys import stdout from bisect import bisect_left as binl from copy import copy, deepcopy from collections import defaultdict mod = 1 def intin(): input_tuple = input().split() if len(input_tuple) <= 1: return int(input_tuple[0]) return tuple(map(int, input_tuple)) def intina(): return [int(i) for i in input().split()] def intinl(count): return [intin() for _ in range(count)] def modadd(x, y): global mod return (x + y) % mod def modmlt(x, y): global mod return (x * y) % mod def lcm(x, y): while y != 0: z = x % y x = y y = z return x def combination(x, y): assert x >= y if y > x // 2: y = x - y ret = 1 for i in range(0, y): j = x - i i = i + 1 ret = ret * j ret = ret // i return ret def get_divisors(x): retlist = [] for i in range(1, int(x**0.5) + 3): if x % i == 0: retlist.append(i) retlist.append(x // i) return retlist def get_factors(x): retlist = [] for i in range(2, int(x**0.5) + 3): while x % i == 0: retlist.append(i) x = x // i retlist.append(x) return retlist def make_linklist(xylist): linklist = {} for a, b in xylist: linklist.setdefault(a, []) linklist.setdefault(b, []) linklist[a].append(b) linklist[b].append(a) return linklist def calc_longest_distance(linklist, v=1): distance_list = {} distance_count = 0 distance = 0 vlist_previous = [] vlist = [v] nodecount = len(linklist) while distance_count < nodecount: vlist_next = [] for v in vlist: distance_list[v] = distance distance_count += 1 vlist_next.extend(linklist[v]) distance += 1 vlist_to_del = vlist_previous vlist_previous = vlist vlist = list(set(vlist_next) - set(vlist_to_del)) max_distance = -1 max_v = None for v, distance in distance_list.items(): if distance > max_distance: max_distance = distance max_v = v return (max_distance, max_v) def calc_tree_diameter(linklist, v=1): _, u = calc_longest_distance(linklist, v) distance, _ = calc_longest_distance(linklist, u) return distance ############################################################################### def main(): x = intin() ans = 1 for i in range(2, x + 1): for j in range(2, 999999): k = i**j if k > x: break ans = max(ans, k) print(ans) if __name__ == "__main__": main()
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s479032302
Runtime Error
p03352
Input is given from Standard Input in the following format: X
import math def main(): x = int(input()) sum=0 if x==0 or x==1: sum=x else: for i in range(2,int(math.sqrt(x))+1): j=2 while True: if pow(i,j)<=x: if pow(i,j)>sum: sum=pow(i,j) else: break j+=1 print(sum) main()
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s860510419
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
p = [] p.extend([i**2 for i in range(int(1000 ** (1 / 2)) + 1)]) p.extend([i**3 for i in range(int(1000 ** (1 / 3)) + 1)]) p.extend([i**5 for i in range(int(1000 ** (1 / 5)) + 1)]) p.extend([i**7 for i in range(int(1000 ** (1 / 7)) + 1)]) p.sort() p.append(1001) N = int(input()) for j in range(len(p) - 1): if p[j] <= N < p[j + 1]: print(p[j])
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s266990454
Runtime Error
p03352
Input is given from Standard Input in the following format: X
import sys X = int(sys.stdin.readline()) ans = 0 for i in range(X+1): for j in range(11): tmp = pow(i, j) if tmp <= X: ans = max(ans, tmp) print(ans)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s702474377
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
print(int(int(input()) ** (0.5)) ** 2)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s080808107
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
print((int(int(input()) ** 0.5)) ** 2)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s935695690
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
num = input() num = int(num) print(num * num)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s685969886
Runtime Error
p03352
Input is given from Standard Input in the following format: X
x = int(input()) c = 1 for i in range(1,x): for j in range(2,x) if i**j <= x: c = max(c, i**j) else:break print(c)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s893937283
Runtime Error
p03352
Input is given from Standard Input in the following format: X
# coding: utf-8 # Your code here! from math import sqrt X=int(input()) sqrt_X=int(sqrt(X)) ans=1 for b in range(1,sqrt_X + 1): ##最後は含まないので+1する必要がある for p in range(2,sqrt_X):  ##pは2から始めまる now_num = b**p if now_num <= X and ans <= now_num: ans =now_num print(ans)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s781310492
Runtime Error
p03352
Input is given from Standard Input in the following format: X
lis=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,216,36,343,49,100,1000] for i in range(11,32): t=i*i lis.append(t) listt=list(set(lis)) listt=sorted(listt) a=int(input()) for i in range(300): if a < listt[i]: print (listt[i-1]) break elif a = listt[i]: print(listt[i]) break
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s739075698
Runtime Error
p03352
Input is given from Standard Input in the following format: X
#標準入力 X = int(input()) max_beki = 1 for i in range(1,X): for j in range(2,X): beki = i %% j if beki > max_beki: if beki <= X: max_beki = beki print(max_beki)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s714060915
Runtime Error
p03352
Input is given from Standard Input in the following format: X
x=int(input()) l=[] for b in range (2,32): for i in range (1,10): if b**i <=x: l.apprnd b**i print(max(l))
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s654042679
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
x = int(input()) ans2 = 1 ans3 = 1 ans5 = 1 for i in range(32): if x >= i**2: ans2 = i**2 for i in range(10): if x >= i**3: ans3 = i**3 for i in range(3): if x >= i**5: ans5 = i**5 if max(ans2, ans3, ans5) < 128 < x: print(128) elif max(ans2, ans3, ans5) < 512 < x: print(512) else: print(max(ans2, ans3, ans5))
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s547652772
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
s = int(input()) snooker = [0] * 1000 for p in range(1, 100): for q in range(1, 10): if p**q <= 10000: snooker[10 * (p - 1) + q - 1] = p**q snooker = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1024, 1089, 1156, 1225, 1296, 1331, 1369, 1444, 1521, 1600, 1681, 1728, 1764, 1849, 1936, 2025, 2116, 2187, 2197, 2209, 2304, 2401, 2500, 2601, 2704, 2744, 2809, 2916, 3025, 3125, 3136, 3249, 3364, 3375, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 4913, 5041, 5184, 5329, 5476, 5625, 5776, 5832, 5929, 6084, 6241, 6400, 6561, 6724, 6859, 6889, 7056, 7225, 7396, 7569, 7744, 7776, 7921, 8000, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9261, 9409, 9604, 9801, 10000, ] slist = [0] * 210 for i in range(0, 210): if snooker[i] <= s: slist[i] = snooker[i] print(max(slist))
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s338771808
Runtime Error
p03352
Input is given from Standard Input in the following format: X
x = int(input()) ans = 0 for i in range(1,x): for j in in range(2,x): if i ^ j < x: ans = i ^ j else: break print(ans)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print the largest perfect power that is at most X. * * *
s934026344
Wrong Answer
p03352
Input is given from Standard Input in the following format: X
# solution import io nim = int(input()) mike = 1 for i in range(2, (nim + 1) // 2): kite = 0 counter = 0 while kite <= nim: m = max(mike, kite) kite = i**counter counter += 1 print(mike)
Statement You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
[{"input": "10", "output": "9\n \n\nThere are four perfect powers that are at most 10: 1, 4, 8 and 9. We should\nprint the largest among them, 9.\n\n* * *"}, {"input": "1", "output": "1\n \n\n* * *"}, {"input": "999", "output": "961"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s526262898
Wrong Answer
p02390
An integer $S$ is given in a line.
s = int(input()) sec = int(s % 60) hm = int(s // 60) if hm == 0: print("::" + str(sec)) else: m = int(hm % 60) h = int(hm // 60) print(str(h) + ":" + str(m) + ":" + str(sec))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s833772456
Accepted
p02390
An integer $S$ is given in a line.
S = input() H = int(S) // 3600 M = (int(S) - 3600 * H) // 60 s = int(S) - 3600 * H - 60 * M print(H, M, s, sep=":")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s835026749
Accepted
p02390
An integer $S$ is given in a line.
S = int(input()) M = S // 60 S = S % 60 H = M // 60 M = M % 60 print(H, M, S, sep=":")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s364272298
Accepted
p02390
An integer $S$ is given in a line.
S = int(input()) A = S % 60 B = S // 60 C = B % 60 D = B // 60 print(str(D) + ":" + str(C) + ":" + str(A))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s106051165
Wrong Answer
p02390
An integer $S$ is given in a line.
A = int(input()) print(A / 3600, ":", (A % 3600) / 60, ":", A % 60)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s130078693
Accepted
p02390
An integer $S$ is given in a line.
input = int(input()) h = input / 3600 m = (input / 60) % 60 s = input % 60 print(int(h), int(m), int(s), sep=":")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s008385047
Accepted
p02390
An integer $S$ is given in a line.
try: (n) = int(input()) except: exit hh = n // 3600 mm = (n % 3600) // 60 ss = n % 60 # print ('{:0=2}:{:0=2}:{:0=2}'.format(hh,mm,ss)) print("{}:{}:{}".format(hh, mm, ss))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s830258858
Wrong Answer
p02390
An integer $S$ is given in a line.
X = int(input()) H = X / 3600 X = X % 3600 M = X / 60 X %= 60 print(H, ":", M, ":", X)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s116932098
Accepted
p02390
An integer $S$ is given in a line.
inputtime = int(input()) print(inputtime // 3600, inputtime // 60 % 60, inputtime % 60, sep=":")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s151892914
Accepted
p02390
An integer $S$ is given in a line.
p = input() h = float(p) // 3600 m = float(p) % 3600 // 60 s = float(p) % 3600 % 60 print(int(h), ":", int(m), ":", int(s), sep="")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s073048083
Runtime Error
p02390
An integer $S$ is given in a line.
a = input() b = int(a / 3600) c = int((a % 3600) / 60) d = a % 60 print(str(b) + ":" + str(c) + ":" + d)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s223184766
Runtime Error
p02390
An integer $S$ is given in a line.
ts = input() h = ts / 3600 ts -= h * 3600 m = ts / 60 ts -= m * 60 text = str(h) + ":" + str(m) + ":" + str(ts) print(text)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s795914849
Accepted
p02390
An integer $S$ is given in a line.
time = float(input()) time = time % (24 * 3600) hour = time // 3600 time %= 3600 minutes = time // 60 time %= 60 seconds = time print("%d:%d:%d" % (hour, minutes, seconds))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s667910871
Accepted
p02390
An integer $S$ is given in a line.
S = float(input()) S = S % (24 * 3600) hour = S // 3600 S %= 3600 minutes = S // 60 S %= 60 seconds = S print("%d:%d:%d" % (hour, minutes, seconds))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s393591809
Accepted
p02390
An integer $S$ is given in a line.
given_second = int(input().rstrip()) minute = given_second // 60 hour = minute // 60 minute = minute % 60 second = given_second % 60 print(hour, minute, second, sep=":")
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s546394912
Runtime Error
p02390
An integer $S$ is given in a line.
S_input = input() S_ans = S_input % 60 M = int(S_input / 60) M_ans = M % 60 H_ans = int(M / 60) print("%d:%d:%d" % (H_ans, M_ans, S_ans))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s149344929
Accepted
p02390
An integer $S$ is given in a line.
s=int(input()) print(s//3600, (s%3600)//60, s%60, sep=':')
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s486151638
Runtime Error
p02390
An integer $S$ is given in a line.
a = int(input) b = a % 3600 c = a // 3600 d = b % 60 e = b // 60 print(c, ":", e, ":", d)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s649043275
Wrong Answer
p02390
An integer $S$ is given in a line.
s = int(input()) print(s // 3600, end="") print(":", end="") print(s // 60, end="") print(":", end="") print(s % 60)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s523512933
Wrong Answer
p02390
An integer $S$ is given in a line.
S = int(input()) sec = S % 60 S = S - sec min = (S) % 3600 / 60 S = S - min * 60 hour = S / 3600 print(str(hour) + ":" + str(min) + ":" + str(sec))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s676060319
Accepted
p02390
An integer $S$ is given in a line.
in_time = int(input()) if 0 <= in_time < 86400: tmp1 = 60**2 h = in_time // tmp1 tmp2 = in_time % tmp1 m = tmp2 // 60 t = tmp2 % 60 print(str(h) + ":" + str(m) + ":" + str(t))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s095387889
Wrong Answer
p02390
An integer $S$ is given in a line.
time = int(input("time=:")) H = int(time / 3600) M = int(time % 3600 / 60) S = int(time % 3600 % 60 % 60) print(str(H) + ":" + str(M) + ":" + str(S))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s675421807
Accepted
p02390
An integer $S$ is given in a line.
time = input() time = int(time) print("%s:%s:%s" % (time // 3600, time % 3600 // 60, time % 3600 % 60))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s704283789
Wrong Answer
p02390
An integer $S$ is given in a line.
minute = int(input()) print("{}:{}:{}".format(46979 // 3600, (46979 % 3600) // 60, (46979 % 3600) % 60))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s781423506
Accepted
p02390
An integer $S$ is given in a line.
s = int(input()) m, s = s / 60, s % 60 h, m = m / 60, m % 60 t = (h, m, s) print(":".join(map(str, map(int, t))))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s551523261
Wrong Answer
p02390
An integer $S$ is given in a line.
s = int(input("input time")) print(str(s // 3600) + ":" + str((s // 3600) % 60) + ":" + str((s % 3600) % 60))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s485516256
Wrong Answer
p02390
An integer $S$ is given in a line.
S = int(input()) s = str(S % 60) m = str(S // 60 % 60) h = str(S // 60 // 60) print(s + ":" + m + ":" + h)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s052658554
Accepted
p02390
An integer $S$ is given in a line.
total_seconds = int(input()) hours = total_seconds / (60 * 60) minutes = (total_seconds % (60 * 60)) / 60 seconds = (total_seconds % (60 * 60)) % 60 print("%d:%d:%d" % (hours, minutes, seconds))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s516082623
Wrong Answer
p02390
An integer $S$ is given in a line.
s_ = int(input()) print("%d %d %d" % (s_ // 3600, s_ // 60 % 60, s_ % 60))
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print $h$, $m$ and $s$ separated by ':'. You do not need to put '0' for a value, which consists of a digit.
s844605595
Wrong Answer
p02390
An integer $S$ is given in a line.
print(38400 / 3600)
Watch Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
[{"input": "46979", "output": "13:2:59"}]
Print the answer. * * *
s794985914
Wrong Answer
p03581
Input is given from Standard Input in the following format: A B
from numpy import * A, B = map(int, input().split()) M = 10**9 + 7 U = 2001 C = zeros((U, U), int64) C[0, 0] = 1 for n in range(1, U): C[n, 1:] += C[n - 1, :-1] C[n, :-1] += C[n - 1, :-1] C[n] %= M S = zeros_like(C) S[0] = 1 S[1:] = (C[:-1].cumsum(axis=1) % M).cumsum(axis=1) % M print(sum(C[B - 1, k] * (sum(S[k, : A - k + 1]) % M) % M for k in range(A + 1)))
Statement A + B balls are arranged in a row. The leftmost A balls are colored red, and the rightmost B balls are colored blue. You perform the following operation: * First, you choose two integers s, t such that 1 \leq s, t \leq A + B. * Then, you repeat the following step A + B times: In each step, you remove the first ball or the s-th ball (if it exists) or the t-th ball (if it exists, all indices are 1-based) from left in the row, and give it to Snuke. In how many ways can you give the balls to Snuke? Compute the answer modulo 10^9 + 7. Here, we consider two ways to be different if for some k, the k-th ball given to Snuke has different colors. In particular, the choice of s, t doesn't matter. Also, we don't distinguish two balls of the same color.
[{"input": "3 3", "output": "20\n \n\nThere are 20 ways to give 3 red balls and 3 blue balls. It turns out that all\nof them are possible.\n\nHere is an example of the operation (`r` stands for red, `b` stands for blue):\n\n * You choose s = 3, t = 4.\n * Initially, the row looks like `rrrbbb`.\n * You remove 3rd ball (`r`) and give it to Snuke. Now the row looks like `rrbbb`.\n * You remove 4th ball (`b`) and give it to Snuke. Now the row looks like `rrbb`.\n * You remove 1st ball (`r`) and give it to Snuke. Now the row looks like `rbb`.\n * You remove 3rd ball (`b`) and give it to Snuke. Now the row looks like `rb`.\n * You remove 1st ball (`r`) and give it to Snuke. Now the row looks like `b`.\n * You remove 1st ball (`b`) and give it to Snuke. Now the row is empty.\n\nThis way, Snuke receives balls in the order `rbrbrb`.\n\n* * *"}, {"input": "4 4", "output": "67\n \n\nThere are 70 ways to give 4 red balls and 4 blue balls. Among them, only\n`bbrrbrbr`, `brbrbrbr`, and `brrbbrbr` are impossible.\n\n* * *"}, {"input": "7 9", "output": "7772\n \n\n* * *"}, {"input": "1987 1789", "output": "456315553"}]
For each dataset, output a single line containing the largest possible capacity of a pond that can be built in the garden site described in the dataset. If no ponds can be built, output a single line containing a zero.
s882100977
Wrong Answer
p01103
The input consists of at most 100 datasets, each in the following format. _d w_ _e_ 1, 1 ... _e_ 1, _w_ ... _e_ _d_ , 1 ... _e d, w_ The first line contains _d_ and _w_ , representing the depth and the width, respectively, of the garden site described in the map. They are positive integers between 3 and 10, inclusive. Each of the following _d_ lines contains _w_ integers between 0 and 9, inclusive, separated by a space. The _x_ -th integer in the _y_ -th line of the _d_ lines is the elevation of the unit square cell with coordinates (_x, y_). The end of the input is indicated by a line containing two zeros separated by a space.
def area(x_s, x_e, y_s, y_e): return int((x_e - x_s - 1) * (y_e - y_s - 1)) def minimum_border(A, x_s, x_e, y_s, y_e): min = A[x_s][y_s] for i in range(x_s, x_e + 1): for j in range(y_s, y_e + 1): if A[i][j] < min: min = A[i][j] return min def maximum_inter(A, x_s, x_e, y_s, y_e): max = A[x_s + 1][y_s + 1] for i in range(x_s + 1, x_e): for j in range(y_s + 1, y_e): if A[i][j] > max: max = A[i][j] return max A = [[0 for i in range(10)] for j in range(10)] ans = [] while True: n, m = map(int, input().split()) if n == m == 0: break for i in range(n): tmp = [] tmp = list(map(int, input().split())) tmp.reverse() for j in range(m): A[i][j] = tmp.pop() flag = 0 max_s = 0 for y_s in range(m - 2): for y_e in range(m - 3, m): for x_s in range(n - 2): for x_e in range(n - 3, n): if y_e - y_s < 2 or x_e - x_s < 2: pass else: # print(area(x_s,x_e,y_s,y_e)) if minimum_border(A, x_s, x_e, y_s, y_e) > maximum_inter( A, x_s, x_e, y_s, y_e ): if flag == 0: print("=====") max_s = area(x_s, x_e, y_s, y_e) else: if area(x_s, x_e, y_s, y_e) > max_s: max_s = area(x_s, x_e, y_s, y_e) ans.append(max_s) ans.reverse() for i in range(len(ans)): print(ans.pop())
_A Garden with Ponds_ Mr. Gardiner is a modern garden designer who is excellent at utilizing the terrain features. His design method is unique: he first decides the location of ponds and design them with the terrain features intact. According to his unique design procedure, all of his ponds are rectangular with simple aspect ratios. First, Mr. Gardiner draws a regular grid on the map of the garden site so that the land is divided into cells of unit square, and annotates every cell with its elevation. In his design method, a pond occupies a rectangular area consisting of a number of cells. Each of its outermost cells has to be higher than all of its inner cells. For instance, in the following grid map, in which numbers are elevations of cells, a pond can occupy the shaded area, where the outermost cells are shaded darker and the inner cells are shaded lighter. You can easily see that the elevations of the outermost cells are at least three and those of the inner ones are at most two. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ICPCDomestic2017_C1) A rectangular area on which a pond is built must have at least one inner cell. Therefore, both its width and depth are at least three. When you pour water at an inner cell of a pond, the water can be kept in the pond until its level reaches that of the lowest outermost cells. If you continue pouring, the water inevitably spills over. Mr. Gardiner considers the larger _capacity_ the pond has, the better it is. Here, the capacity of a pond is the maximum amount of water it can keep. For instance, when a pond is built on the shaded area in the above map, its capacity is (3 − 1) + (3 − 0) + (3 − 2) = 6, where 3 is the lowest elevation of the outermost cells and 1, 0, 2 are the elevations of the inner cells. Your mission is to write a computer program that, given a grid map describing the elevation of each unit square cell, calculates the largest possible capacity of a pond built in the site. Note that neither of the following rectangular areas can be a pond. In the left one, the cell at the bottom right corner is not higher than the inner cell. In the right one, the central cell is as high as the outermost cells. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ICPCDomestic2017_C2)
[{"input": "3\n 2 3 2\n 2 1 2\n 2 3 1\n 3 5\n 3 3 4 3 3\n 3 1 0 2 3\n 3 3 4 3 2\n 7 7\n 1 1 1 1 1 0 0\n 1 0 0 0 1 0 0\n 1 0 1 1 1 1 1\n 1 0 1 0 1 0 1\n 1 1 1 1 1 0 1\n 0 0 1 0 0 0 1\n 0 0 1 1 1 1 1\n 6 6\n 1 1 1 1 2 2\n 1 0 0 2 0 2\n 1 0 0 2 0 2\n 3 3 3 9 9 9\n 3 0 0 9 0 9\n 3 3 3 9 9 9\n 0 0", "output": "3\n 1\n 9"}]
Print the expected value of |x - 1/3| modulo 10^9 + 7, as described in Notes. * * *
s997037185
Runtime Error
p03094
Input is given from Standard Input in the following format: N
n = int(input()) list = [] a = [] for i in range(n): list.append(int(input)) for i in range(1, n): for j in range(1, i): if list[i] == j: a.insert(j, j) if a == list: for i in range(n): print(list[i]) else: print(-1)
Statement We have a round pizza. Snuke wants to eat one third of it, or something as close as possible to that. He decides to cut this pizza as follows. First, he divides the pizza into N pieces by making N cuts with a knife. The knife can make a cut along the segment connecting the center of the pizza and some point on the circumference of the pizza. However, he is very poor at handling knives, so the cuts are made at uniformly random angles, independent from each other. Then, he chooses one or more **consecutive** pieces so that the total is as close as possible to one third of the pizza, and eat them. (Let the total be x of the pizza. He chooses consecutive pieces so that |x - 1/3| is minimized.) Find the expected value of |x - 1/3|. It can be shown that this value is rational, and we ask you to print it modulo 10^9 + 7, as described in Notes.
[{"input": "2", "output": "138888890\n \n\nThe expected value is \\frac{5}{36}.\n\n* * *"}, {"input": "3", "output": "179012347\n \n\nThe expected value is \\frac{11}{162}.\n\n* * *"}, {"input": "10", "output": "954859137\n \n\n* * *"}, {"input": "1000000", "output": "44679646"}]
Print the answer. * * *
s494515574
Accepted
p02685
Input is given from Standard Input in the following format: N M K
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**18 MOD = 998244353 class ModTools: """階乗たくさん使う時用のテーブル準備""" def __init__(self, MAX, MOD): """MAX:階乗に使う数値の最大以上まで作る""" MAX += 1 self.MAX = MAX self.MOD = MOD factorial = [1] * MAX factorial[0] = factorial[1] = 1 for i in range(2, MAX): factorial[i] = factorial[i - 1] * i % MOD inverse = [1] * MAX inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD) for i in range(MAX - 2, -1, -1): inverse[i] = inverse[i + 1] * (i + 1) % MOD self.fact = factorial self.inv = inverse def nCr(self, n, r): """組み合わせの数""" if n < r: return 0 r = min(r, n - r) numerator = self.fact[n] denominator = self.inv[r] * self.inv[n - r] % self.MOD return numerator * denominator % self.MOD N, M, K = MAP() mt = ModTools(N, MOD) ans = 0 for k in range(K + 1): ans += M * pow(M - 1, N - k - 1, MOD) * mt.nCr(N - 1, k) ans %= MOD print(ans)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s845878526
Runtime Error
p02685
Input is given from Standard Input in the following format: N M K
n, k = map(int, input().split()) (*A,) = map(int, input().split()) A = [0] + A m = 60 DP = [[None for j in range(m)] for i in range(n + 1)] for i in range(n + 1): DP[i][0] = A[i] for j in range(1, m): for i in range(n + 1): DP[i][j] = DP[DP[i][j - 1]][j - 1] K = list(bin(k)[2:][::-1]) i = 1 for j, b in enumerate(K): if b == "1": i = DP[i][j] print(i)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s723244289
Wrong Answer
p02685
Input is given from Standard Input in the following format: N M K
print(0)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s308803827
Accepted
p02685
Input is given from Standard Input in the following format: N M K
def pow_mod(a, b, m): if b == 0: return 1 elif b % 2 == 0: d = pow_mod(a, b // 2, m) return (d * d) % m else: return (a * pow_mod(a, b - 1, m)) % m def comb(n, c, m): upe = 1 dow = 1 for i in range(1, c + 1): upe = upe * n % m dow = dow * i % m n -= 1 return upe * pow_mod(dow, m - 2, m) % m def modinv(a, m): b = m u = 1 v = 0 while b: t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, u u %= m if u < 0: u += m return u MOD = 998244353 def solve(N, M, K): MOD = 998244353 U = N - 1 - K color = M * pow_mod(M - 1, U, MOD) % MOD c = comb(N - 1, U, MOD) % MOD # print("c0=%d"%c) answer = (c * color) % MOD # print("a0", answer) # print("U=%d"%U) for j in range(N - K, N): c = ((c * (N - j) % MOD) * modinv(j, MOD)) % MOD # assert c == comb(N-1, j, MOD) color = (color * (M - 1)) % MOD a = (c * color) % MOD answer += a return answer % MOD N, M, K = map(int, input().split()) print(solve(N, M, K))
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s379518327
Accepted
p02685
Input is given from Standard Input in the following format: N M K
##through permutations and combinations we can reduce ans to ## Summation N-1CK(m-1)^(N-1-K) import sys sys.setrecursionlimit(100000000) DP = {} mod = 998244353 product = {} N = 1000001 # array to store inverse of 1 to N factorialNumInverse = [None] * (N + 1) # array to precompute inverse of 1! to N! naturalNumInverse = [None] * (N + 1) # array to store factorial of # first N numbers fact = [None] * (N + 1) # Function to precompute inverse of numbers def InverseofNumber(p): naturalNumInverse[0] = naturalNumInverse[1] = 1 for i in range(2, N + 1, 1): naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p # Function to precompute inverse # of factorials def InverseofFactorial(p): factorialNumInverse[0] = factorialNumInverse[1] = 1 # precompute inverse of natural numbers for i in range(2, N + 1, 1): factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p # Function to calculate factorial of 1 to N def factorial(p): fact[0] = 1 # precompute factorials for i in range(1, N + 1): fact[i] = (fact[i - 1] * i) % p # Function to return nCr % p in O(1) time def Binomial(N, R, p): # n C r = n!*inverse(r!)*inverse((n-r)!) ans = ((fact[N] * factorialNumInverse[R]) % p * factorialNumInverse[N - R]) % p return ans def getproduct(M, n): # product=(M-1)^n global mod, product fact = 1000 if n - 1 in product: product[n] = (M * product[n - 1]) % mod return (M * product[n - 1]) % mod if n < fact: return (M**n) % mod else: Q = int(n / fact) R = n % fact prev = 1 for q in range(Q): prev = (prev * ((M**fact) % mod)) % mod prev = prev * ((M**R) % mod) product[n] = prev % mod return prev % mod def ncr(n, r, p): # initialize numerator # and denominator num = den = 1 for i in range(r): num = (num * (n - i)) % p den = (den * (i + 1)) % p return (num * pow(den, p - 2, p)) % p def G(N, M, K): global mod res = 0 for k in range(K, -1, -1): res = ( res + ( (Binomial(N - 1, k, mod)) % mod * (M * getproduct(M - 1, N - k - 1)) % mod ) % mod ) % mod return res % mod def F(curr, N, M, K): global DP if (curr, K) in DP: return DP[(curr, K)] if curr == N: return 1 if curr == 0: return M * F(curr + 1, N, M, K) else: a = 0 if K > 0: a = F(curr + 1, N, M, K - 1) b = (M - 1) * F(curr + 1, N, M, K) DP[(curr, K)] = a + b return a + b N, M, K = map(int, input().strip().split()) InverseofNumber(mod) InverseofFactorial(mod) factorial(mod) # print(F(0,N,M,K)%mod) print(G(N, M, K))
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s372777655
Accepted
p02685
Input is given from Standard Input in the following format: N M K
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) class Combination: def __init__(self, n_max, mod=10**9 + 7): # O(n_max + log(mod)) self.mod = mod f = 1 self.fac = fac = [f] for i in range(1, n_max + 1): f = f * i % mod fac.append(f) f = pow(f, mod - 2, mod) self.facinv = facinv = [f] for i in range(n_max, 0, -1): f = f * i % mod facinv.append(f) facinv.reverse() # "n 要素" は区別できる n 要素 # "k グループ" はちょうど k グループ def __call__(self, n, r): # self.C と同じ return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod def C(self, n, r): if not 0 <= r <= n: return 0 return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod def P(self, n, r): if not 0 <= r <= n: return 0 return self.fac[n] * self.facinv[n - r] % self.mod def H(self, n, r): if (n == 0 and r > 0) or r < 0: return 0 return ( self.fac[n + r - 1] * self.facinv[r] % self.mod * self.facinv[n - 1] % self.mod ) def rising_factorial(self, n, r): # 上昇階乗冪 n * (n+1) * ... * (n+r-1) return self.fac[n + r - 1] * self.facinv[n - 1] % self.mod def stirling_first( self, n, k ): # 第 1 種スターリング数 lru_cache を使うと O(nk) # n 要素を k 個の巡回列に分割する場合の数 if n == k: return 1 if k == 0: return 0 return ( self.stirling_first(n - 1, k - 1) + (n - 1) * self.stirling_first(n - 1, k) ) % self.mod def stirling_second( self, n, k ): # 第 2 種スターリング数 O(k + log(n)) # n 要素を区別のない k グループに分割する場合の数 if n == k: return 1 # n==k==0 のときのため return ( self.facinv[k] * sum( (-1) ** (k - m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k + 1) ) % self.mod ) def balls_and_boxes_3( self, n, k ): # n 要素を区別のある k グループに分割する場合の数 O(k + log(n)) return ( sum( (-1) ** (k - m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k + 1) ) % self.mod ) def bernoulli(self, n): # ベルヌーイ数 lru_cache を使うと O(n**2 * log(mod)) if n == 0: return 1 if n % 2 and n >= 3: return 0 # 高速化 return ( -pow(n + 1, self.mod - 2, self.mod) * sum(self.C(n + 1, k) * self.bernoulli(k) % self.mod for k in range(n)) ) % self.mod def faulhaber(self, k, n): # べき乗和 0^k + 1^k + ... + (n-1)^k # bernoulli に lru_cache を使うと O(k**2 * log(mod)) bernoulli が計算済みなら O(k * log(mod)) return ( pow(k + 1, self.mod - 2, self.mod) * sum( self.C(k + 1, j) * self.bernoulli(j) % self.mod * pow(n, k - j + 1, self.mod) % self.mod for j in range(k + 1) ) % self.mod ) def lah(self, n, k): # n 要素を k 個の空でない順序付き集合に分割する場合の数 O(1) return self.C(n - 1, k - 1) * self.fac[n] % self.mod * self.facinv[k] % self.mod def bell( self, n, k ): # n 要素を k グループ以下に分割する場合の数 O(k**2 + k*log(mod)) return sum(self.stirling_second(n, j) for j in range(1, k + 1)) % self.mod n, m, k = map(int, read().split()) mod = 998244353 comb = Combination(n, mod) ans = 0 n -= 1 for i in range(k + 1): ans += comb.C(n, n - i) * m * pow(m - 1, n - i, mod) % mod ans %= mod print(ans)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s629207763
Runtime Error
p02685
Input is given from Standard Input in the following format: N M K
# ------------------------------warmup---------------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # -------------------game starts now----------------------------------------------------- n, m, k = map(int, input().split()) a = [0] * (k + 1) a[0] = 1 for i in range(1, k + 1): a[i] = (a[i - 1] * (n - i)) // (i) e = pow(m - 1, n - 1) ans = 0 mod = 998244353 for i in range(k + 1): ans += ((m % mod) * (e % mod) * (a[i] % mod)) % mod e //= m - 1 ans %= mod print(ans)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s642149521
Runtime Error
p02685
Input is given from Standard Input in the following format: N M K
n, m, k = (int(i) for i in input().split()) l = [0 for i in range(k + 2)] l[k] = m for i in range(n - 1): r = [] for j in range(k + 1): r.append(l[j] * (m - 1) + l[j + 1]) r.append(0) l = r print(sum(r) % 998244353)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the answer. * * *
s556945310
Runtime Error
p02685
Input is given from Standard Input in the following format: N M K
from itertools import product import math N, M, K = map(int, input().split()) total_case = product(range(M), repeat=N) # すべての色の塗り方の数 count = math.pow(M, N) # すべての色の塗り方をAとしてリスト化 A = [] for i in total_case: A.append(i) # 各塗り方に対して隣り合う色が存在するか判定する for j in A: # 色が被ってよい組み合わせ数 limit = K out_flag = 0 for p in range(N - 1): if j[p] == j[p + 1]: limit = limit - 1 if limit < 0: out_flag = -1 break if out_flag == -1: count = count - 1 # 答えの算出および表示 ans = int(count % 998244353) print(ans)
Statement There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[{"input": "3 2 1", "output": "6\n \n\nThe following ways to paint the blocks satisfy the conditions: `112`, `121`,\n`122`, `211`, `212`, and `221`. Here, digits represent the colors of the\nblocks.\n\n* * *"}, {"input": "100 100 0", "output": "73074801\n \n\n* * *"}, {"input": "60522 114575 7559", "output": "479519525"}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s423488634
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) print(in(((a+b)*h)/2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s466051411
Accepted
p03997
The input is given from Standard Input in the following format: a b h
print(eval("(i+i)*i//2".replace("i", "int(input())")))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s592549941
Accepted
p03997
The input is given from Standard Input in the following format: a b h
print((int(input()) + int(input())) * (int(input()) // 2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s601039514
Accepted
p03997
The input is given from Standard Input in the following format: a b h
f = lambda: int(input()) print((f() + f()) * f() // 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s822720657
Accepted
p03997
The input is given from Standard Input in the following format: a b h
print(int((int(input()) + int(input())) / 2 * int(input())))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s021739060
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print((int(input()+int(input())*(int(input())//2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s381848307
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print((int(input())+int(input()))*int(input()//2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s698907992
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
print()
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s100961777
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a, b, h = [int(input()) for _ in range(3)] print((a+b)*h / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s113856889
Accepted
p03997
The input is given from Standard Input in the following format: a b h
from functools import reduce def main(): # 初期値用:十分大きい数(100億) # 1e10 # 初期値用:十分小さい数(-100億) # -1e10 # 1文字のみを読み込み # s = input().rstrip() # スペース区切りで標準入力を配列として読み込み # s = input().rstrip().split(' ') # 1文字ずつ標準入力を文字列として読み込み # s = list(input().rstrip()) # 位置文字ずつ標準入力を数値配列として読み込み # X = [int(_) for _ in input().split()] N = int(input().rstrip()) K = int(input().rstrip()) X = int(input().rstrip()) print(int((N + K) * X / 2)) if __name__ == "__main__": main()
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s965365186
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
a, b, c = [str(input()) for i in range(3)] current = "a" while True: cur = current[len(current) - 1] if cur == "a": current += a[0] a = a[1:] elif cur == "b": current += b[0] b = b[1:] elif cur == "c": current += c[0] c = c[1:] if a == "" or b == "" or c == "": print(current[len(current) - 1].upper()) break
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s653006324
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
s = {} for i in range(3): s[chr(97 + i)] = input() turn = "a" while True: if not s[turn]: break else: turn = s[turn][0] s[turn] = s[turn][1:] print(turn.upper())
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s429869777
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a = 3 >>> b = 6 >>> h = 8 >>> print((a + b) * h / 2 ) 36.0 >>>
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s735053546
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
h,w,n=map(int,input().split()) d={} for _ in range(n): a,b=map(int,input().split()) for i in (-1,0,1): for j in (-1,0,1): if 2<=a+i<=h-1 and 2<=b+j<=w-1: d.setdefault((a+i,b+j),0) d[a+i,b+j]+=1 r=[0]*10 for i in d.values(): r[i]+=1 r[0]=(h-2)*(w-2)-sum(r) for i in r: print(i)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s051750174
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
def iroha(): a, b, c = [int(input()) for i in range(3)] num = (a + b) * c / 2 result = int(num) print(result)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s021432289
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
s = [input() for i in range(3)] l = [len(s[i]) for i in range(3)] abc = [0, 0, 0] now = 0 while abc[now] != l[now]: s_sub = s[now][abc[now]] abc[now] += 1 now = 0 if s_sub == "a" else 1 if s_sub == "b" else 2 print("A" if now == 0 else "B" if now == 1 else "C")
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s337531469
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
#!/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 bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right 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(): a, b, h = IR(3) print((a + b) * h / 2) return # B def B(): 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__": A()
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s926432446
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
S = {c: list(input()) for c in "abc"} s = "a" while S[s]: s = S[s].pop(0) print(s.upper())
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s095401889
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h //2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s903221184
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
lis = [int(input()) for i in range 3] print(int(lis[0]*lis[1]*lis[2]/2))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s872909399
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
# -*- coding: utf-8 -*- N = 3 # N = int(input()) s = [input() for range(N)] a = s[1] b = s[2] h = s[3] S = ((a + b)*h/2) print(str(S))
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s245565380
Wrong Answer
p03997
The input is given from Standard Input in the following format: a b h
A = list(input().strip()) B = list(input().strip()) C = list(input().strip()) current = A currentName = "A" while True: if len(current) == 0: break card = current.pop(0) if card is "a": current = A currentName = "A" elif card is "b": current = B currentName = "B" else: current = C currentName = "C" print(currentName)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s493015546
Accepted
p03997
The input is given from Standard Input in the following format: a b h
lst = [int(input()) for x in range(3)] print((lst[0] + lst[1]) * lst[2] // 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]
Print the area of the given trapezoid. It is guaranteed that the area is an integer. * * *
s406702516
Runtime Error
p03997
The input is given from Standard Input in the following format: a b h
a, b, h = (int(input()) for i in range(3)) print((a+b)*h / 2)
Statement You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. ![](https://atcoder.jp/img/arc061/1158e37155d46a42e90f31566478e6da.png) An example of a trapezoid Find the area of this trapezoid.
[{"input": "3\n 4\n 2", "output": "7\n \n\nWhen the lengths of the upper base, lower base, and height are 3, 4, and 2,\nrespectively, the area of the trapezoid is (3+4)\u00d72/2 = 7.\n\n* * *"}, {"input": "4\n 4\n 4", "output": "16\n \n\nIn this case, a parallelogram is given, which is also a trapezoid."}]