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 number of the ways to paint tiles, modulo 998244353. * * *
s504432097
Wrong Answer
p03332
Input is given from Standard Input in the following format: N A B K
n, a, b, kk = map(int, input().split()) MOD = 998244353 N = n + 10 fact = [0 for _ in range(N)] invfact = [0 for _ in range(N)] fact[0] = 1 for i in range(1, N): fact[i] = fact[i - 1] * i % MOD invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD) for i in range(N - 2, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD def nCk(n, k): if k < 0 or n < k: return 0 else: return fact[n] * invfact[k] * invfact[n - k] % MOD def rbg(n, a, b, k): x = 0 while x <= b: if (a * x) % b == k % b: y = (k - a * x) // b s = 0 while y >= 0: c = x + y if c <= n: d = 0 else: d = c - n e = min(x, y) z = 0 while d <= e: z += nCk(n, d) * nCk(n - d, x - d) * nCk(n - x, y - d) z %= MOD d += 1 s += z s %= MOD x += b y -= a return s % MOD x += 1 return 0 print(rbg(n, a, b, kk))
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s786453727
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
input = input().split(" ") n = int(input[0]) a = int(input[1]) b = int(input[2]) k = int(input[3]) import math def comb(n, k): return math.factorial(n) / (math.factorial(k) * math.factorial(n - k)) def func(n, a, b, k): if k < a and k < b: print(1) return combination = [] temp = k num_a = 0 while temp >= num_a: num_b = (temp - num_a) / b if num_b % 1 == 0: combination.append([int(num_a / a), int(num_b)]) num_a += a color_combi = [] for c in combination: max_num = min(c[0] + 1, n) for num_red in range(0, c[0] + 1): num_green = c[0] - num_red num_blue = c[1] - num_green if num_red >= 0 and num_green >= 0 and num_blue >= 0: if num_red + num_blue + num_green <= n: color_combi.append([num_red, num_green, num_blue]) result = 0 for c in color_combi: result += comb(n, c[0]) * comb(n - c[0], c[1]) * comb(n - c[0] - c[1], c[2]) print(result) func(n, a, b, k)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s353391452
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
W, H, x, y = map(int, input().split()) v = x / W h = y / H if v and h == 0.5: print(W * H / 2, 1) else: print(W * H / 2, 0)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s812550768
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
// Created by sz #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n; map<long long, int> cnt; int main(){ #ifdef LOCAL freopen("./input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); cin>>n; long long x; for (int i = 1; i <= n; i++){ cin>>x; cnt[x] ++; } vector<long long> sid; vector<long long> sid4; for (auto i = cnt.rbegin(); i != cnt.rend(); i++){ if(i->second >=4)sid4.push_back(i->first); if(i->second >=2)sid.push_back(i->first); } long long mx = 0; if(sid4.size()>0)mx = max(mx, sid4[0]*sid4[0]); if(sid.size()>=2)mx = max(mx, sid[0]*sid[1]); if(sid4.size()>0 && sid.size()>0)mx = max(mx, sid4[0]*sid[0]); cout<<mx<<endl; return 0; }
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s679609608
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
import string char = string.ascii_lowercase numbering = {} for i in range(26): numbering[char[i]] = i A = input() n = len(A) next = [[n + 1] * 26 for i in range(n + 1)] next[n][numbering[A[n - 1]]] = n for i in range(n - 1, -1, -1): for j in range(26): next[i][j] = next[i + 1][j] next[i][numbering[A[i]]] = i dp = ["z" * n for i in range(n + 1)] dp[n] = "a" for i in range(n - 1, -1, -1): m = 0 length = n for c in range(26): if next[i][c] > n and char[c] < dp[i]: dp[i] = char[c] break else: if length > len(dp[next[i][c] + 1]) + 1: length = len(dp[next[i][c] + 1]) + 1 m = c try: if ( dp[i] > char[m] + dp[next[i][m] + 1] and len(dp[i]) > len(dp[next[i][m] + 1]) + 1 ): dp[i] = char[m] + dp[next[i][m] + 1] except IndexError: pass print(dp[0])
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s611494717
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = input() B = input() def f(horizontal_flag): if horizontal_flag[0]: if horizontal_flag[1]: return 3 else: return 1 else: return 2 if N == 1: print(3) else: if A[0] == A[1]: counter = 6 initial_num = 2 horizontal_flag = [0, 1] else: counter = 3 initial_num = 1 horizontal_flag = [0, 1] for i in range(initial_num, N): if i == N - 1: if horizontal_flag[1] == 2: horizontal_flag[1] = 1 counter *= f(horizontal_flag) else: horizontal_flag[1] = 0 counter *= f(horizontal_flag) elif A[i] == A[i + 1]: horizontal_flag[1] = 2 else: if horizontal_flag[1] == 2: horizontal_flag[1] = 1 counter *= f(horizontal_flag) else: horizontal_flag[1] = 0 counter *= f(horizontal_flag) horizontal_flag[0] = horizontal_flag[1] print(counter % 1000000007)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s618945873
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) l = [0,0] c = 0 for j in range(len(a)-1): if(c => 2): print(l[0] * l[1]) if(a[j] == a[j+1]): del l[0] l.append(a[j]) j += 1 c += 1
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s835861431
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) l = [0,0] c = 0 for j in range(len(a)-1): if(count => 2): print(l[0] * l[1]) if(a[j] == a[j+1]): del l[0] l.append(a[j]) j += 1 c += 1
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s303184850
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) a = sorted(list(map(int, input().split())), reverse=True) l = [0,0] c = 0 for j in range(len(a)-1): if(count => 2): print(l[0] * l[1]) if(a[j] == a[j+1]): del l[0] l.append(a[j]) j += 1 count += 1
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s478643634
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
import collections n = int(input()) alist = list(map(int,input().split())) adic = collections.Counter(alist) for k,v in adic.items(): if v == 1: del(adic[k]) sort_adic = sorted(adic.items(), reverse = True, key = lamda x:x[1]) li = list(sort_adic.items()) print(li[0][1]*li[1][1])
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s786241559
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = [int(a) for a in input().split()] dic = {} for a in A: dic[a] = dic.get(a,0) + 1 2p = [] ans = 0 for k in dic: if dic[k] >= 4: ans = max(ans,dic[k]**2) elif dic[k] >= 2: 2p.append(dic[k]) if len(2p)>=2: 2p.sort(reverse=True) ans = max(ans,2p[0]*2p[1]) print(ans)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s928547583
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
import collections n = int(input()) l = map(int, input().split()) c = collections.Counter(l) c = sorted(c.items(), key=lambda c:c[0], reverse=True) ans = 1 cnt = 0 for key,val in c: if cnt=0 and val>=4: ans=key**2 break if val>=2: ans*=key cnt+=1 if cnt == 2: break else: ans = 0 print(ans)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s986020071
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
= int(input()) a = list(map(int, input().split())) bar_list = {} for i in a: if i in bar_list: bar_list[i] += 1 else: bar_list[i] = 1 saved = -1 ans = 0 for k, v in sorted(bar_list.items(), key=lambda x:x[1]): if v > 1: if saved < 0: saved = k else: ans = saved * k break print(ans)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s716684131
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
def inpl(): return [int(i) for i in input().split()] H, W = inpl() ans = max(H, W) S = "" for _ in range(H): S += input() T = [[0] * (W - 1)] for i in range(H - 1): t = [] for j in range(W - 1): r = ( S[i * W + j] + S[i * W + j + 1] + S[(i + 1) * W + j] + S[(i + 1) * W + j + 1] ) t.append(r.count(".") % 2) ts = [0] * (W - 1) for i, k in enumerate(t): if k: continue ts[i] = T[-1][i] + 1 T.append(ts) for iT in T[1:]: stack = [] for i, l in enumerate(iT): while stack: w, h = stack[-1] if h > l: dw, dh = stack.pop() ans = max(ans, (dh + 1) * (i - dw + 1)) continue break stack.append((i, l)) while stack: dw, dh = stack.pop() ans = max(ans, (dh + 1) * (i - dw + 2)) print(ans)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s331441183
Wrong Answer
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
import collections n = int(input()) A = list(map(int, input().split())) a = collections.Counter(A) firstnum = 0 secondnum = 0 firstl = 0 secondl = 0 values, counts = zip(*a.most_common()) if len(values) == 1 and counts[0] >= 4: print(values[0] ** 2) else: for i, j in a.items(): if i >= firstl and j >= 2: secondnum = firstnum firstnum = j secondl = firstl firstl = i elif secondl <= i < firstl and j >= 2: secondnum = j secondl = i print(firstl * secondl)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s334660073
Accepted
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
from statistics import mean, median, variance, stdev import numpy as np import sys import math import fractions import itertools import copy import collections from operator import itemgetter # 以下てんぷら def j(q): if q == 1: print("Yes") elif q == 0: print("No") exit(0) """ def ct(x,y): if (x>y):print("+") elif (x<y): print("-") else: print("?") """ def ip(): return int(input()) def printrow(a): for i in range(len(a)): print(a[i]) def combinations(n, r): if n < r: return 0 return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def permutations(n, r): if n < r: return 0 return math.factorial(n) // math.factorial(n - r) def lcm(x, y): return (x * y) // fractions.gcd(x, y) n = ip() # 入力整数1つ # h,m= (int(i) for i in input().split()) #入力整数横2つ以上 a = [int(i) for i in input().split()] # 入力整数配列 # a = input() #入力文字列 # a = input().split() #入力文字配列 # n = ip() #入力セット(整数改行あり)(1/2) # a=[ip() for i in range(n)] #入力セット(整数改行あり)(2/2) # a=[input() for i in range(n)] #入力セット(整数改行あり)(2/2) # jの変数はしようできないので注意 # 全足しにsum変数使用はsum関数使用できないので注意 # こっから本文 a.sort() c = 1 cnum = a[0] s = [] for i in range(1, n): if a[i] != cnum: if c > 1: s.append(cnum) if c > 3: s.append(cnum) c = 1 cnum = a[i] else: c += 1 if c > 1: s.append(cnum) if c > 3: s.append(cnum) s.sort(reverse=True) if len(s) < 2: print(0) else: print(s[0] * s[1])
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s061825867
Wrong Answer
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) A = list(map(int, input().split())) up2_max = 0 up2_2nd = 0 up4_max = 0 for cand in list(set(A)): num = A.count(cand) if num >= 2 and cand > up2_max: up2_max, up2_2nd = cand, up2_max elif num >= 4: up4_max = cand print(max(up2_max * up2_2nd, up4_max**2))
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s124211018
Runtime Error
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N=int(input()) A=[int(i) for i in input().split()] A.sort() lis=[] dic={} for i in range(N): try: dic[A[N-i-1]]=dic[A[N-i-1]]+1 if dic[A[N-i-1]]%2==0: lis+=[A[N-i-1]] except: dict.setdefault(A[N-i-1],1) if len(lis)==2: break if len(lis)<2:print(0) else:print(lis[0]*lis[1])
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0. * * *
s584937103
Wrong Answer
p03627
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) a = list(map(int, input().split())) s = set(sorted(a)) v = [i for i in s] v.reverse() print(v) b_1 = 0 b_2 = 0 for i in v: n = a.count(i) if n >= 2 and b_1 != 0 and b_2 == 0: b_2 = i if n >= 2 and b_1 == 0: b_1 = i if n >= 4 and b_2 == 0: b_2 = i print(b_1 * b_2)
Statement We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
[{"input": "6\n 3 1 2 4 2 1", "output": "2\n \n\n1 \\times 2 rectangle can be formed.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n \n\nNo rectangle can be formed.\n\n* * *"}, {"input": "10\n 3 3 3 3 4 4 4 5 5 5", "output": "20"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s883539514
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
A = int(input()) B = list(map(int, input().split())) print(sum(B) / 2 - max(B) / 2)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s623890605
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
n = int(input()) arr = [int(x) for x in input().split()] arr = sum(arr) print(arr / n)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s284219730
Accepted
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
N = int(input()) v_array = list(map(int, input().split())) v_array.sort() # print(v_array) v_sum = 0 bairitu = 1 for i, v in enumerate(v_array[::-1]): if i != N - 1: bairitu *= 0.5 v_sum += bairitu * v print(v_sum)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s364204704
Accepted
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
N = int(input()) values = map(int, input().split()) # 最初に投入した具材ほど半分の半分の半分の……になっていく # つまり小さい順に投入すればいい sorted_values = sorted(values) # 順番に足していく anser_values = [0.0 for _ in range(N)] anser_values[0] = (sorted_values[0] + sorted_values[1]) / 2 for n in range(2, N): anser_values[n - 1] = (anser_values[n - 2] + sorted_values[n]) / 2 print(anser_values[N - 2])
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s735430163
Accepted
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
# -*- coding: utf-8 -*- # input n = int(input()) numbers = map(int, input().split()) ans = [[0] * n for i in range(n)] numbers = sorted(numbers, reverse=False) for x, i in enumerate(numbers): ans[0][x] = i # print("input to for") # print(ans) for x, ansc in enumerate(ans): # print("x times") # print(x) if ansc.count(0) == n - 1: print(ansc[n - 1]) break for y, i in enumerate(ansc): if i != 0 and y == 0: # print("first run") ansc[1] = (float(ansc[0]) + ansc[1]) / 2 ansc[0] = 0 break else: # print("second run") if y > 0: if ansc[y - 1] == 0 and ansc[y] != 0: ansc[y + 1] = (float(ansc[y]) + ansc[y + 1]) / 2 ansc[y] = 0 break # print("y=") # print(y) # print(ansc) # print("before") # print(ans) ans[x + 1] = sorted(ans[x + 1], reverse=False, key=float) ans[x + 1] = ansc
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s237865807
Runtime Error
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
N, Q = map(int, input().split()) l = [[1, 0, 0]] for i in range(1, N): a, b = map(int, input().split()) l.append([b, a, 0]) l.sort() for i in range(Q): p, x = map(int, input().split()) l[p - 1][2] += x t = [l[0][2]] for i in range(1, N): t.append(t[l[i][1] - 1] + l[i][2]) print(*t)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s528174128
Accepted
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
N = int(input()) u = list(map(int, input().split())) s_u = sorted(u) for x in range(N - 1): s_u = sorted(s_u) tmp = s_u.copy() val = (tmp[0] + tmp[1]) / 2 if len(s_u) != 1: s_u.remove(tmp[0]) s_u.remove(tmp[1]) s_u.insert(0, val) print(s_u[0])
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s881612923
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
values = [int(x) for x in input().split()] combined_value = values[0] sliced_values = values[1:] for value in sliced_values: combined_value = (combined_value + value) / 2 print(round(combined_value, 5))
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s435640105
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
n = int(input()) a = sum(list(map(int, input().split()))) print(a * n / (2**n))
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s022500045
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
print(1000)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining. Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}. * * *
s272768517
Wrong Answer
p02935
Input is given from Standard Input in the following format: N v_1 v_2 \ldots v_N
number = int(input()) powers = input().rstrip().split() # print(number) # print(powers) ordered = sorted(powers) answer = 0 for i in range(number): answer = answer + ((1 / 2) ** (number - i)) * int(ordered[i]) trueanswer = answer + int(ordered[0]) * (1 / 2) ** number print(trueanswer)
Statement You have a pot and N ingredients. Each ingredient has a real number parameter called _value_ , and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.
[{"input": "2\n 3 4", "output": "3.5\n \n\nIf you start with two ingredients, the only choice is to put both of them in\nthe pot. The value of the ingredient resulting from the ingredients of values\n3 and 4 is (3 + 4) / 2 = 3.5.\n\nPrinting `3.50001`, `3.49999`, and so on will also be accepted.\n\n* * *"}, {"input": "3\n 500 300 200", "output": "375\n \n\nYou start with three ingredients this time, and you can choose what to use in\nthe first composition. There are three possible choices:\n\n * Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.\n * Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.\n * Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.\n\nThus, the maximum possible value of the last ingredient remaining is 375.\n\nPrinting `375.0` and so on will also be accepted.\n\n* * *"}, {"input": "5\n 138 138 138 138 138", "output": "138"}]
Print the median of m. * * *
s349395759
Wrong Answer
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import sys from operator import itemgetter input = sys.stdin.readline def compress(lis, n=2, last_sort=False): length = len(lis) first_value = -1 for i in range(n): lis.sort(key=itemgetter(i)) value = first_value index = 0 for j in range(length): if lis[j][i] != value: index += 1 value = lis[j][i] lis[j][i] = index if last_sort: lis.sort() return lis class BIT: def __init__(self, n): self.n = n self.bit = [0] * (n + 1) self.value = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.bit[i] i -= i & -i return s def add(self, i, x): # assert i > 0 self.value[i] += x while i <= self.n: self.bit[i] += x i += i & -i def subtract(self, i, x): self.add(i, -x) def init(self, n, lis): self.n = n self.bit = [0] * (n + 1) self.value = lis for i in range(n): self.add(i, lis[i]) def get_value(self, i): return self.value[i] def get_sum(self, i, j): return self.sum(j) - self.sum(i) def lower_bound(self, x): # 和がx以上になる最小のインデックス if x <= 0: return 0 l, r = 0, self.n while r - l > 1: index = (r + l) // 2 if self.sum(index) >= x: r = index else: l = index if self.sum(l) >= x: return l return r def upper_bound(self, x): # 和がx以下になる最大のインデックス if x <= 0: return 0 l, r = 0, self.n while r - l > 1: index = (r + l) // 2 if self.sum(index) <= x: l = index else: r = index if self.sum(r) <= x: return r return l def reset(self): self.bit = [0] * (self.n + 1) self.value = [0] * (self.n + 1) def main(): n = int(input()) b = list(map(int, input().split())) a = [[int(i), int(x)] for i, x in enumerate(b)] compress(a) key_list = dict() for i, x in a: key_list[x] = b[i - 1] a = [x[1] for x in a] l, r = 0, max(a) bit = BIT(n + 3) border = (n + 1) * n // 4 + 1 while r - l > 1: k = (l + r) // 2 s = [0] * (n + 1) for i in range(n): if a[i] >= k: s[i + 1] += 1 else: s[i + 1] -= 1 s[i + 1] += s[i] floor = min(s) for i in range(n + 1): s[i] -= floor - 1 count = 0 bit.reset() for i in range(n + 1): count += bit.sum(s[i]) bit.add(s[i] + 1, 1) if count >= border: l = k else: r = k print(key_list[r]) if __name__ == "__main__": main()
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s318220562
Runtime Error
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import sys def median_of_medians(A, i): # divide A into sublists of len 5 sublists = [A[j : j + 5] for j in range(0, len(A), 5)] medians = [sorted(sublist)[len(sublist) // 2] for sublist in sublists] if len(medians) <= 5: pivot = sorted(medians)[len(medians) // 2] else: # the pivot is the median of the medians pivot = median_of_medians(medians, len(medians) // 2) # partitioning step low = [j for j in A if j < pivot] high = [j for j in A if j > pivot] k = len(low) if i < k: return median_of_medians(low, i) elif i > k: return median_of_medians(high, i - k - 1) else: # pivot = k return pivot n = int(input()) a = list(map(int, sys.stdin.readline().split())) if n == 1: print(a[0]) elif n == 2: a.sort() print(a[-1]) else: print(median_of_medians(a, n // 2 + 1))
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s074573785
Accepted
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import itertools N = int(input()) A = [int(_) for _ in input().split()] def check(x): class SegmentTree: """ Parameters ---------- array : list to construct segment tree from f : func binary operation of the monoid e : identity element of the monoid size : int limit for array size """ def __init__(self, array, f, e, size): self.f = f self.e = e self.size = size self.n = n = len(array) self.dat = [e] * n + array + [e] * (2 * size - 2 * n) self.build() def build(self): dat, n, f = self.dat, self.n, self.f for i in range(n - 1, 0, -1): dat[i] = f(dat[i << 1], dat[i << 1 | 1]) def modify(self, p, v): """ set value at position p (0-indexed) """ f, n, dat = self.f, self.n, self.dat p += n dat[p] = v while p > 1: dat[p >> 1] = f(dat[p], dat[p ^ 1]) p >>= 1 def query(self, l, r): """ result on interval [l, r) (0-indexed) """ f, e, n, dat = self.f, self.e, self.n, self.dat res = e l += n r += n while l < r: if l & 1: res = f(res, dat[l]) l += 1 if r & 1: r -= 1 res = f(res, dat[r]) l >>= 1 r >>= 1 return res cumsum = list(itertools.accumulate([0] + [1 if a <= x else -1 for a in A])) # sum([l:r)) = cumsum[r] - cumsum[l] >= 0 # ⇔ cumsum[l] <= cumsum[r] e = 0 size = 2 * N + 10 ST = SegmentTree([e] * size, f=lambda x, y: x + y, e=e, size=size) count = 0 for c in cumsum: c += N + 5 count += ST.query(0, c + 1) ST.modify(c + 1, ST.query(c + 1, c + 2) + 1) return 2 * count > N * (N + 1) // 2 A_sorted = [0] + sorted(set(A)) + [10**10] lb = 0 rb = len(A_sorted) - 1 # check(x) == Trueとなる最小のx while rb - lb > 1: mid = (rb + lb) // 2 if check(A_sorted[mid]): rb = mid else: lb = mid print(A_sorted[rb])
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s007635468
Accepted
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
from itertools import accumulate N = int(input()) As = list(map(int, input().split())) Bs = sorted(As) M = N * (N + 1) // 2 def isOK(mid): Am = Bs[mid] Ss = [1 if A >= Am else -1 for A in As] Ss = list(accumulate([0] + Ss)) def makeBIT(numEle): numPow2 = 2 ** (numEle - 1).bit_length() data = [0] * (numPow2 + 1) return data, numPow2 def addValue(iA, A): iB = iA + 1 while iB <= numPow2: data[iB] += A iB += iB & -iB def getSum(iA): iB = iA + 1 ans = 0 while iB > 0: ans += data[iB] iB -= iB & -iB return ans data, numPow2 = makeBIT(N + 1) iSs = list(range(N + 1)) iSs.sort(key=lambda iS: Ss[iS]) odrSs = [0] * (N + 1) for odrS, iS in enumerate(iSs): odrSs[iS] = odrS num = 0 for odrS in odrSs: num += getSum(odrS) addValue(odrS, 1) return num >= (M + 1) // 2 ng, ok = N, -1 while abs(ok - ng) > 1: mid = (ng + ok) // 2 if isOK(mid): ok = mid else: ng = mid print(Bs[ok])
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s544943407
Runtime Error
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int, input().split(" "))) b = sorted(a) m = b[N // 2] lst = [] dic = {} def dfs(l, r, mid): dic[(l, r)] = 1 lst.append(mid) if l == r: return if (r - l + 1) % 2 == 0: if a[r] < mid: if not (l, r - 1) in dic: dfs(l, r - 1, mid) else: if not (l, r - 1) in dic: c = sorted(a[l:r]) mid_ = c[(len(c) // 2)] dfs(l, r - 1, mid_) if a[l] < mid: if not (l + 1, r) in dic: dfs(l + 1, r, mid) elif not (l + 1, r) in dic: c = sorted(a[l + 1 : r + 1]) mid_ = c[(len(c) // 2)] dfs(l + 1, r, mid_) else: if a[r] > mid: if not (l, r - 1) in dic: dfs(l, r - 1, mid) else: if not (l, r - 1) in dic: c = sorted(a[l:r]) mid_ = c[len(c) // 2] dfs(l, r - 1, mid_) if a[l] > mid: if not (l + 1, r) in dic: dfs(l + 1, r, mid) else: if not (l + 1, r) in dic: c = sorted(a[l + 1 : r + 1]) mid_ = c[(len(c) // 2)] dfs(l + 1, r, mid_) dfs(0, N - 1, m) lst.sort() l = len(lst) print(lst[(l // 2)])
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s587275917
Wrong Answer
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import itertools N = int(input()) A = [int(_) for _ in input().split()] class BinaryIndexedTree: """ Parameters ---------- array : list to construct BIT from f : func binary operation of the abelian group fi : func inverse mapping of f i.e. f(a, b) == c <-> fi(c, a) == b e : identity element of the abelian group size : int limit for array size """ def __init__(self, array, f, fi, e, size): self.f = f self.fi = fi self.e = e self.size = size self.n = len(array) self.dat = [e] * (size + 1) self.array = [e] * size self.build(array) def build(self, array_): for i, v in enumerate(array_): self.modify(i, v) def modify(self, p, v): """ set value at position p (0-indexed) """ fi, dat, f, size, array = self.fi, self.dat, self.f, self.size, self.array dv = fi(v, array[p]) array[p] = v p += 1 while p <= size: dat[p] = f(dat[p], dv) p += p & -p def query(self, l, r): """ result on interval [l, r) (0-indexed) """ return self.fi(self._query(r), self._query(l)) def _query(self, p): dat, f, res = self.dat, self.f, self.e while p: res = f(res, dat[p]) p -= p & -p return res e = 0 size = 2 * N + 2 f = lambda a, b: a + b fi = lambda c, a: c - a offset = N def check(x): cumsum = list(itertools.accumulate([0] + [1 if a <= x else -1 for a in A])) # sum([l:r)) = cumsum[r] - cumsum[l] >= 0 # ⇔ cumsum[l] <= cumsum[r] BIT = BinaryIndexedTree([e] * size, f=f, fi=fi, e=e, size=size) count = 0 for c in cumsum: c += offset count += BIT.query(0, c + 1) BIT.modify(c + 1, BIT.query(c + 1, c + 2) + 1) return 2 * count > N * (N + 1) // 2 A_sorted = [0] + sorted(set(A)) + [10**10] lb = 0 rb = len(A_sorted) - 1 # check(x) == Trueとなる最小のx while rb - lb > 1: mid = (rb + lb) // 2 if check(A_sorted[mid]): rb = mid else: lb = mid print(rb)
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s501611510
Runtime Error
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
import sys def select(A, i): # A is a list, i is the ith element in that ordered list # NOTE all elements must be unique T = list(A) if len(A) <= 5: # Base case, just find ith element T = list(A) T.sort() return T[i] p = median_of_medians(A) (A_l, A_r, i_p) = partition(A, p) if i_p == i: return p elif i_p < i: return select(A_r, i - i_p - 1) else: # i_p > i return select(A_l, i) def median_of_medians(A): B = list() # B will hold medians of sublists itrs, i = len(A) // 5, 0 for j in range(itrs): # divide list into sublists of len 5 sub_list = A[i : i + 5] m = median(sub_list) B.append(m) i += 5 end = len(A) % 5 if end != 0: B.append(median(A[-end:])) # add the last group to the pot p = select(B, len(B) // 2) return p def partition(A, p): # splits the list into left and right half where # everything less is in the left list (A_l, A_r, i_p) = [], [], 0 for elem in A: if p > elem: A_l.append(elem) elif p < elem: A_r.append(elem) i_p = len(A_l) return A_l, A_r, i_p def median(A): # A cheat to find the median in our base case T = list(A) # copies list! T.sort() i = len(T) / 2 # in list of 4 selects the 3rd element return T[int(i)] n = int(input()) a = list(map(int, sys.stdin.readline().split())) pivot = median_of_medians(a) print(pivot)
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the median of m. * * *
s858396803
Runtime Error
p03277
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = (int(input()) x = [int(i) for i in input().split()] x = sorted(x) if n==1: print(x[0]) elif n==2: print(x[1]) elif n%2==1: print(x[(n+1)//2]) else: print(x[n//2+1])
Statement We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m.
[{"input": "3\n 10 30 20", "output": "30\n \n\nThe median of each contiguous subsequence of a is as follows:\n\n * The median of (10) is 10.\n * The median of (30) is 30.\n * The median of (20) is 20.\n * The median of (10, 30) is 30.\n * The median of (30, 20) is 30.\n * The median of (10, 30, 20) is 20.\n\nThus, m = (10, 30, 20, 30, 30, 20) and the median of m is 30.\n\n* * *"}, {"input": "1\n 10", "output": "10\n \n\n* * *"}, {"input": "10\n 5 9 5 9 8 9 3 5 4 3", "output": "8"}]
Print the total length of the ray's trajectory. * * *
s241157045
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
n, x = map(int, input().strip().split()) z = n - 2 * x y = n - x an = 0 an += 3 * x + y an += z * (x // z + 1) # x=x//z # z-=2*x while not z < x: an += z * (x // z + 1) if not x % z == 0: an += 1 z -= 2 * x print(an)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s926180917
Wrong Answer
p04048
The input is given from Standard Input in the following format: N X
N, X = map(int, input().split()) if X == N / 2: print(3 * X) else: if X > N / 2: X = N - X L = X + (N - X) + X rest_ab = N - 2 * X while rest_ab > X: L += 2 * X # print('>X',L) rest_ab -= X if rest_ab == X: L += 2 * X elif rest_ab < X: # print('rest_ab=', rest_ab) L += X + 2 * (X - 1) + 1 print(L)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s311100241
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
N,X = input().split() N,X = int(N), int(X) answer = X+ (N-X) def rhombus(N,X): if N<X: temp = N N = X X = temp if X==1: return N+1 if X==0: return 0 if N%X == 0: return X*(N//X)*2-X else: k = N//X return k*2*X + rhombus(X,N-(k*X)) answer = answer + rhombus(N-X,X) print(answer)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s999658450
Accepted
p04048
The input is given from Standard Input in the following format: N X
calculate_remainder = lambda pl, pr: ( 2 * (pl // pr) * pr - pr if pl % pr == 0 else 2 * (pl // pr) * pr + calculate_remainder(pr, pl % pr) ) n, k = (int(s) for s in input().strip().split(" ")) print(str(n + calculate_remainder(n - k, k)))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s742191763
Wrong Answer
p04048
The input is given from Standard Input in the following format: N X
Input_num = [int(x) for x in input().split()] N = Input_num[0] X = Input_num[1] Total_Length = 2 * X + N + 3 * (X // 2) print(Total_Length)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s002545282
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
def gcd(a,b): if a%b==0: return b else: return gcd(b,a%b) N,X=map(int,input().split()) print(3*(N-gcd(N,X))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s352506225
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
def gcd(a,b): if a%b==0: return b else: return gcd(b,a%b): N,X=map(int,input().split()) print(3*(N-gcd(N,X))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s171165520
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
n,x=map(int,input().split()) ans=0 if x<n/2: a=x b=n-x ans+=x+n while True: if b%a=0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a elif x=n/2: ans=3*x elif x>n/2: a=n-x b=x ans+=x while True: if b%a=0: ans+=a*2*(b/a) break else: ans+=a*2*(b//a) a,b=b%a,a print(ans)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s561951220
Wrong Answer
p04048
The input is given from Standard Input in the following format: N X
# x, N-x, x # N-x-x N, x = list(map(int, input().split())) ll = 0 if x * 2 < N: ll = x + N if (N - x * 2) == x: ll += 2 * x elif (N - 2 * x) > x: ll += (N - x * 2) / x * 2 * x else: ll += x + x / (N - x * 2) * 2 - (N - x * 2) elif x * 2 == N: ll = x + x + x else: ll = x ll += x / (N - x) * 2 * (N - x) print(int(ll))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s733850664
Accepted
p04048
The input is given from Standard Input in the following format: N X
a, x = map(int, input().split()) q, p = sorted((a - x, x)) while q: a += (p // q * 2 - (p % q < 1)) * q p, q = q, p % q print(a)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s873049898
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
a,b = map(int,input().split()) s = a/b print(3b*(s-1))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s978740743
Wrong Answer
p04048
The input is given from Standard Input in the following format: N X
x, n = [int(i) for i in input().split()] print((n - x) * 3 + (n - x * 2) * 3)
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s091075627
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
from fractions n,x=map(int,input().split()) print(3*(n-fractions.gcd(n,x)))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the total length of the ray's trajectory. * * *
s764156874
Runtime Error
p04048
The input is given from Standard Input in the following format: N X
from fractions import gcd n,m=map(int,input().split()) print(3*(n-gcd(n,m))
Statement Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of _Mysterious Light_. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap = X. (The size of the rifle is negligible.) Now, the rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light. There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror! When the ray comes back to the rifle, the ray will be absorbed. The following image shows the ray's trajectory where N = 5 and X = 2. ![btriangle.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png) It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of N and X. Find the total length of the ray's trajectory.
[{"input": "5 2", "output": "12\n \n\nRefer to the image in the Problem Statement section. The total length of the\ntrajectory is 2+3+2+2+1+1+1 = 12."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s287533698
Accepted
p03324
Input is given from Standard Input in the following format: D N
# -*- coding: utf-8 -*- # IMPORT ############################################################################################################### import sys # システム sys.setrecursionlimit(10**6) # 再帰処理の上限変更 from collections import deque, Counter # キュー・個数カウント from itertools import accumulate, permutations, combinations # 累積和・順列・組み合わせ from operator import itemgetter # ソート補助 from bisect import bisect_left, bisect_right, bisect # 二分探索 from heapq import heappop, heappush # プライオリティキュー from fractions import gcd # 最大公約数 from math import ceil, floor, sqrt, cos, sin, tan, pi # 数学処理 from copy import deepcopy # オブジェクトコピー import numpy as np # 数値計算 # MAIN ################################################################################################################# def main(): # Init ############################################################################################################# im = InputManager() # Input ############################################################################################################ d, n = im.inputMultiple() # Logic ############################################################################################################ message = "" if n == 100: message += "101" else: message += str(n) for i in range(d): message += "00" # Output ########################################################################################################### print(message) # Return ########################################################################################################### return # INPUT MANAGER ######################################################################################################## class InputManager(object): def __init__(self): pass @staticmethod def inputSingle(dtype=int): return dtype(input()) @staticmethod def inputMultiple(dtype=int, aslist=False): if aslist: return list(map(dtype, input().split())) else: return map(dtype, input().split()) @staticmethod def input2D(h, dtype=int): return [list(map(dtype, input().split())) for i in range(h)] # CALL MAIN ############################################################################################################ main()
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s880904252
Accepted
p03324
Input is given from Standard Input in the following format: D N
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_col(H): """ H is number of rows A列、B列が与えられるようなとき ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合 """ ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return tuple(map(list, zip(*ret))) def read_matrix(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return ret # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため MOD = 10**9 + 7 INF = 2**31 # 2147483648 > 10**9 # default import from collections import defaultdict, Counter, deque from operator import itemgetter from itertools import product, permutations, combinations from bisect import bisect_left, bisect_right # , insort_left, insort_right # https://atcoder.jp/contests/abc100/tasks/abc100_b D, N = read_ints() if N == 100: N += 1 print(N * (100**D))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s196868015
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
d, n = map(int, input().split()) ans = [] if d == 0: x = 1 while True: if x % 100 != 0 and x % 10000 != 0: ans.append(x) x += 1 if len(ans) == n: break elif d == 1: x = 100 while True: if x % 10000 != 0: ans.append(x) x += 100 if len(ans) == n: break else: x = 10000 while True: if x % 100000000 != 0: ans.append(x) x += 10000 if len(ans) == n: break print(ans[-1])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s549552875
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
d,n=map(int, input().split()) if d == 0 and n == 100: print(101) elif d == 1 and n == 100 print(10001) elif d == 2 and n == 100 print(1000001) else: print(100**d * n)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s262143798
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
a,b=list(map(int,input().split())) if a=0: print(b) eixt() print(100**a*b)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s836713907
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
i = list(map(int, input().split())) num = 100 ** i[0] print(num * i[1])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s669307257
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D,N = map(int,input().split()) ans = [] for i in range(10000000): if i%(100**D) == 0: ans.append(i) if len(ans) == N: print(ans[N])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s286637720
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D, N = int(input()) print(100 * (D + N) if D > 0 else N)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s156869596
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
b, c = map(int, input().split()) print((100**c) * b)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s104576017
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
A, N = map(int, input().split()) print(N * 100**A)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s573582211
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
A = list(map(int, input().split())) a = A[0] b = A[1] a = 100**a s = a * b print(int(s))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s909844936
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
d,n=map(int,input().split()) print(100**d*n)d,n=map(int,input().split()) if n==100: print(100**d*(n+1)) else: print(100**d*n)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s454180661
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
x, y = map(int, input().split()) ans = 0 num = 100**x for i in range(1, y + 1): ans = num * i if y == 0: ans = num print(ans)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s026160324
Accepted
p03324
Input is given from Standard Input in the following format: D N
d, n = input().split() d = int(d) n = int(n) if d == 0: x = 1 a = [] for i in range(101): if not x == 100: a.append(x) x += 1 print(a[n - 1]) if d == 1: y = 100 b = [] for j in range(101): if not y == 10000: b.append(y) y += 100 print(b[n - 1]) if d == 2: c = [] z = 10000 for k in range(101): if not z == 1000000: c.append(z) z += 10000 print(c[n - 1])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s315531252
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
inp = input() inp2 = inp.split() A=int(inp2[0]) B=int(inp2[1]) C = B*(100**A) if B == 100: if A = 0: C = 101 elif A = 1: C = 10001 elif A = 2: C = 1000001 print(C)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s296004914
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
#input D, N = map(int, input().split()) #output if D == 0: if N = 100: print(101) else: print(N) elif D == 1: if N == 100: print(10100) else: print(100*N) else: if N == 100: print(1010000) else: print(100**2*N)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s443530080
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
d,n = [int(i) for i in input().split()] int answer = 0 if d == 0 : answer = n elif d == 1: answer = 100*n elif d == 2: answer = 10000*n else: answer = 0 print(answer)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s353951903
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D,N=map(int,input().split()) if N==100: print((N+1)*(100**D) else: print(N*(100**D)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s814379491
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D,N=map(int,input().split()) if N==100: (N+1*(100**D) else: print(N*(100**D)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s979706625
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
nums = [int(e) for e in input().split()] print(pow(100, nums[0]) * nums[1])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s355433994
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D, N = list(map(int, input().split())) if N==100 and D==0 print(101) else: print(N*100**D)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s867721353
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D, N = map(int, input().split()) if n = 100: print((100 ** D) * (N+1)) else: print((100 ** D) * N)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s861100663
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
d,n = map(int,input().split()) if n <= 99: print(n * (100 ** d)) elif n = 100: print(101 * (100 ** d))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s824557300
Accepted
p03324
Input is given from Standard Input in the following format: D N
L, R = map(int, input().split()) print((100**L) * (int((R - 1) / 99) + R))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s208339671
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
l = list(map(int, input().split())) print(l[1] * 100 ** l[0])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s913956636
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
print(eval("100**" + input().replace(" ", "*")))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s354497595
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
d, a = map(int, input().split()) print(100**d * a)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s556704960
Accepted
p03324
Input is given from Standard Input in the following format: D N
D, N = map(int, input().split()) a, b, c = [], [], [] i = 1 while len(a) < 100: if i % 100 != 0: a.append(i) i += 1 i = 100 while len(b) < 100: if i % 100 == 0: j = i // 100 if j % 100 != 0: b.append(i) i += 100 i = 10000 while len(c) < 100: if i % 10000 == 0: j = i // 10000 if j % 100 != 0: c.append(i) i += 10000 if D == 0: print(a[N - 1]) elif D == 1: print(b[N - 1]) else: print(c[N - 1])
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s221754199
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D, N = map(int, input().split()) if N = 100: print((100 ** D) * (101)) else: print((100 ** D) * N)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s501148051
Accepted
p03324
Input is given from Standard Input in the following format: D N
i = list(map(int, input().split())) if i[1] == 100: i[1] = 101 print(i[1] * (100 ** i[0]))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s053178101
Accepted
p03324
Input is given from Standard Input in the following format: D N
A, B = list(map(int, input().split())) if B == 100: B = 101 print((100**A) * B)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s291312128
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D,N = map(int,input().split() print(100**D*N if N!=100 else 100**D*(N+1))
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s889116648
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
d, n = [int(i) for i in input().split()] result = n for j in range(d): result *= 100 print(result)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s915341616
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
n, m = map(int, input().split()) if n == 0: print(m) elif n == 1: print(m * 100) elif n == 2: print(m * 10000)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s158900305
Wrong Answer
p03324
Input is given from Standard Input in the following format: D N
headerData = input().split() d = int(headerData[0]) n = headerData[1] answer = n + "00" * d print(answer)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s643710115
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
D,N=list(map(int, input().split())) print(10^^D*N)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the N-th smallest integer that can be divided by 100 exactly D times. * * *
s913880639
Runtime Error
p03324
Input is given from Standard Input in the following format: D N
#abc100 b d,n=map(int,input(.split())) ans=n*100**d print(ans)
Statement Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 **exactly** D times. Find the N-th smallest integer that would make Ringo happy.
[{"input": "0 5", "output": "5\n \n\nThe integers that can be divided by 100 exactly 0 times (that is, not\ndivisible by 100) are as follows: 1, 2, 3, 4, 5, 6, 7, ... \nThus, the 5-th smallest integer that would make Ringo happy is 5.\n\n* * *"}, {"input": "1 11", "output": "1100\n \n\nThe integers that can be divided by 100 exactly once are as follows: 100, 200,\n300, 400, 500, 600, 700, 800, 900, 1 \\ 000, 1 \\ 100, ... \nThus, the integer we are seeking is 1 \\ 100.\n\n* * *"}, {"input": "2 85", "output": "850000\n \n\nThe integers that can be divided by 100 exactly twice are as follows: 10 \\\n000, 20 \\ 000, 30 \\ 000, ... \nThus, the integer we are seeking is 850 \\ 000."}]
Print the answer. * * *
s185784140
Accepted
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") AtoZ = "abcdefghijklmnopqrstuvwxyz" ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors #####MakePrimes###### def make_primes(N): max = int(math.sqrt(N)) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X)))) #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# N = I() A = IL() M = max(A) dic = DD(int) for a in A: dic[a] += 1 if dic[0] != 1 or A[0] != 0: print(0) exit() else: ans = 1 for i in range(M): ans *= pow(dic[i], dic[i + 1]) ans %= 998244353 print(ans)
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s142608347
Runtime Error
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
import functools import operator result = functools.reduce(operator.mul, li) N = int(input()) D = list(map(int, input().split())) ans=1 if not D[0]==0: ans=0 else: D.remove(0) ans = functools.reduce(operator.mul, D) print(ans)
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s871565463
Runtime Error
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
import heapq class Dijkstra: def __init__(self, rote_map, start_point, goal_point=None): self.rote_map = rote_map self.start_point = start_point self.goal_point = goal_point def execute(self): num_of_city = len(self.rote_map) dist = [10**16 for _ in range(num_of_city)] prev = [10**16 for _ in range(num_of_city)] dist[self.start_point] = 0 heap_q = [] heapq.heappush(heap_q, (0, self.start_point)) while len(heap_q) != 0: prev_cost, src = heapq.heappop(heap_q) if dist[src] < prev_cost: continue if src == self.goal_point: return prev_cost for dest, cost in self.rote_map[src].items(): if dist[dest] > prev_cost + cost: dist[dest] = prev_cost + cost heapq.heappush(heap_q, (dist[dest], dest)) prev[dest] = src return -1 n, m = map(int, input().split()) route_map = [dict() for _ in range(n)] for i in range(m): u, v, a = map(int, input().split()) u, v = u - 1, v - 1 route_map[u][v] = a for i in range(n - 1): u, v = i + 1, i route_map[u][v] = 0 # ゴールまでの最短経路 print(Dijkstra(route_map, 0, n - 1).execute())
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s132336941
Wrong Answer
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
from copy import deepcopy from sys import exit, setrecursionlimit import math from collections import defaultdict, Counter, deque from fractions import Fraction as frac import bisect import sys input = sys.stdin.readline setrecursionlimit(1000000) def main(): n = int(input()) d = list(map(int, input().split())) z = defaultdict(int) for i in d: z[i] += 1 mx = max(d) for i in range(mx + 1): if z[i] == 0: print(0) return if d[0] != 0 and z[0] != 1: print(0) return ans = 1 for i in reversed(range(1, mx + 1)): ans *= z[i - 1] ** z[i] print(ans % 998244353) 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 def zip(a): mae = a[0] ziparray = [mae] for i in range(1, len(a)): if mae != a[i]: ziparray.append(a[i]) mae = a[i] return ziparray def is_prime(n): if n < 2: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def list_replace(n, f, t): return [t if i == f else i for i in n] def base_10_to_n(X, n): X_dumy = X out = "" while X_dumy > 0: out = str(X_dumy % n) + out X_dumy = int(X_dumy / n) if out == "": return "0" return out def gcd(l): x = l.pop() y = l.pop() while x % y != 0: z = x % y x = y y = z l.append(min(x, y)) return gcd(l) if len(l) > 1 else l[0] class Queue: def __init__(self): self.q = deque([]) def push(self, i): self.q.append(i) def pop(self): return self.q.popleft() def size(self): return len(self.q) def debug(self): return self.q class Stack: def __init__(self): self.q = [] def push(self, i): self.q.append(i) def pop(self): return self.q.pop() def size(self): return len(self.q) def debug(self): return self.q class graph: def __init__(self): self.graph = defaultdict(list) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) self.graph[t].append(f) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) self.graph[t].remove(f) def linked(self, f): return self.graph[f] class dgraph: def __init__(self): self.graph = defaultdict(set) def addnode(self, l): f, t = l[0], l[1] self.graph[f].append(t) def rmnode(self, l): f, t = l[0], l[1] self.graph[f].remove(t) def linked(self, f): return self.graph[f] main()
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s738001045
Accepted
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
MOD = 998244353 class Fp(int): def __new__(self, x=0): return super().__new__(self, x % MOD) def inv(self): return self.__class__(super().__pow__(MOD - 2, MOD)) def __add__(self, value): return self.__class__(super().__add__(value)) def __sub__(self, value): return self.__class__(super().__sub__(value)) def __mul__(self, value): return self.__class__(super().__mul__(value)) def __floordiv__(self, value): return self.__class__(self * self.__class__(value).inv()) def __pow__(self, value): return self.__class__(super().__pow__(value % (MOD - 1), MOD)) __radd__ = __add__ __rmul__ = __mul__ def __rsub__(self, value): return self.__class__(-super().__sub__(value)) def __rfloordiv__(self, value): return self.__class__(self.inv() * value) def __iadd__(self, value): self = self + value return self def __isub__(self, value): self = self - value return self def __imul__(self, value): self = self * value return self def __ifloordiv__(self, value): self = self // value return self def __ipow__(self, value): self = self**value return self def __neg__(self): return self.__class__(super().__neg__()) from collections import Counter N, *D = map(int, open(0).read().split()) ans = Fp(D[0] == 0 and 0 not in D[1:]) C = Counter(D) for k, v in sorted(C.items())[1:]: ans *= Fp(C[k - 1]) ** v if k - 1 in C else 0 print(ans)
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s159178794
Accepted
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
N, D = open(0) (*D,) = map(int, D.split()) c = [0] * -~max(D) for i in D: c[i] += 1 a = D[0] < 1 == c[0] for i, j in zip(c, c[1:]): a *= i**j print(a % 998244353)
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print the answer. * * *
s428618962
Wrong Answer
p02866
Input is given from Standard Input in the following format: N D_1 D_2 ... D_N
N = int(input()) D = [int(x) for x in input().split()] print(0)
Statement Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
[{"input": "4\n 0 1 1 2", "output": "2\n \n\nFor example, a tree with edges (1,2), (1,3), and (2,4) satisfies the\ncondition.\n\n* * *"}, {"input": "4\n 1 1 1 1", "output": "0\n \n\n* * *"}, {"input": "7\n 0 3 2 1 2 2 1", "output": "24"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go. * * *
s839889610
Runtime Error
p03774
The input is given from Standard Input in the following format: N M a_1 b_1 : a_N b_N c_1 d_1 : c_M d_M
a, b = map(int, input().split()) x = [] z = [] m = 19999999999999 s = 1 for i in range(a): ta, tb = map(int, input().split()) x.append([ta, tb]) for i in range(a): ta, tb = map(int, input().split()) z.append([ta, tb]) for ta, tb in x: s = 0 m = 19999999999999 for n, (s, y) in enumerate(z): print(n, s, y) # print(m , abs(s-ta)+abs(y-tb)) if m >= abs(s - ta) + abs(y - tb): m = abs(s - ta) + abs(y - tb) s = n print(s + 1)
Statement There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_. The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|. Here, |x| denotes the absolute value of x. If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to?
[{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go. * * *
s960184558
Accepted
p03774
The input is given from Standard Input in the following format: N M a_1 b_1 : a_N b_N c_1 d_1 : c_M d_M
N, M = map(int, input().strip().split(" ")) persons = [list(map(int, input().strip().split(" "))) for _ in range(N)] checkpoints = [list(map(int, input().strip().split(" "))) for _ in range(M)] def distance(person, checkpoint): return sum(abs(a - b) for a, b in zip(person, checkpoint)) for person in persons: print( sorted( [ [distance(person, checkpoint), i + 1] for i, checkpoint in enumerate(checkpoints) ] )[0][1] )
Statement There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_. The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|. Here, |x| denotes the absolute value of x. If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to?
[{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go. * * *
s380571887
Runtime Error
p03774
The input is given from Standard Input in the following format: N M a_1 b_1 : a_N b_N c_1 d_1 : c_M d_M
N, M = map(int, input().split()) A = [] for i in range(N): a, b = map(int, input().split()) A.append([a, b]) C=[] for i in range(M): c, d = map(int, input().split()) C.append([c, d]) for i in range(N): saitei = float("inf") ans = 0 for j in range(M): if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei: saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) ans = j+1 print(ans)
Statement There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_. The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|. Here, |x| denotes the absolute value of x. If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to?
[{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go. * * *
s467080212
Wrong Answer
p03774
The input is given from Standard Input in the following format: N M a_1 b_1 : a_N b_N c_1 d_1 : c_M d_M
a = list(map(int, input().split(" "))) br = [] cr = [] for i in range(a[0]): l = list(map(int, input().split(" "))) br.append(l) for j in range(a[1]): m = list(map(int, input().split(" "))) cr.append(m) count = 10**8 inde = 0 for b in br: for k, c in enumerate(cr): d = abs(b[0] - c[0]) + abs(b[1] - c[1]) if d < count: count = d for l, c in enumerate(cr): if count == abs(b[0] - c[0]) + abs(b[1] - c[1]): print(l + 1) break
Statement There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_. The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|. Here, |x| denotes the absolute value of x. If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to?
[{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}]