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 blocks in K-city.
* * * | s781745626 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | s=input()
print(s[0]+str(len(s-2))+s[-1]) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s896336466 | Accepted | p03635 | Input is given from Standard Input in the following format:
n m | temp = input()
n, m = temp.split()
city = (int(n) - 1) * (int(m) - 1)
print(city)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s032644515 | Accepted | p03635 | Input is given from Standard Input in the following format:
n m | numone, numtwo = map(int, input().split())
answer = (numone - 1) * (numtwo - 1)
print(answer)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s148932156 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | string = input("")
first = string[0]
last = string[len(string) - 1]
mid = str(len(string[1 : len(string) - 1]))
print(first + mid + last)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s136339962 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m |
import sys
def solve(n,m):
return n*m//2
def readQuestion():
ws = sys.stdin.readline().strip().split()
a = int(ws[0])
b = int(ws[1])
return (a, b,)
def main():
solve(*readQuestion())
# Uncomment before submission
main() | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s575171205 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | letters = input()
n = len(letters)
print(letters[0] + str(n - 2) + letters[n - 1])
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s921436635 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | words = input()
l = len(words)
output = words[0] + str(l - 2) + words[l - 1]
print(output)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s891900896 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | n, m = map(int,input().split())
if n <= 1 or m <= 1:
print(0)
else:
print((n-1) * (m-1) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s262805738 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | r = map(lambda x: int(x) - 1, input().split())
print(r[0] * r[1])
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s434246044 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | input_str = input("")
start = input_str[:1]
end = input_str[-1:]
print(start + str((len(input_str) - 2)) + end)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s809531672 | Accepted | p03635 | Input is given from Standard Input in the following format:
n m | row, col = map(int, input().split())
print((row - 1) * (col - 1))
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s280811834 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | word = str(input())
print(word[0] + str(len(word) - 2) + word[-1])
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s889132893 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | n, m = map( int, input().split())
print((n-1)*(m-1))a | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s307941429 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | n, m = map(intm input().split())
print((n - 1) * (m - 1)) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s664966287 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | ls = list(input())
print(ls[0] + str(len(ls) - 2) + ls[-1])
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s140159281 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | m,n=input().slide()
x=(m-1)n
print(x) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s213236793 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | print(int(input()) * 2)
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s798308531 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | print(int(eval(input().replace(" ", "*")) / 2))
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s976188449 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | l = input().split()
H = int(l[0])
W = int(l[1])
N = int(input())
c = [[0 for i in range(W)] for j in range(H)]
color_num = [int(i) for i in input().split()]
row = 0
column = 0
for i in range(N):
index = color_num[i]
for j in range(0, index):
c[row][column] = i + 1
if column % (W - 1) == 0 and column != 0:
row += 1
column = 0
else:
column += 1
for i in range(H):
if i % 2 == 1:
print("change")
c[i].reverse()
for i in range(0, H):
for j in range(0, W):
print(c[i][j], end=" ")
print("")
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s242875666 | Accepted | p03635 | Input is given from Standard Input in the following format:
n m | a = input().split()
print((int(a[0]) - 1) * (int(a[1]) - 1))
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s733215699 | Accepted | p03635 | Input is given from Standard Input in the following format:
n m | l = [int(i) for i in input().split()]
print((l[0] - 1) * (l[1] - 1))
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s356392545 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | n, m = map(int, input().split())
ans = (n-1)*(m-1)
print(ans)) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s467561275 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | def main():
s = input()
print(s[0] + str(len(s)-2) + s[-1])
if __name__ == '__main__':
main() | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s017068448 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | n = input()
print("{}{}{}".format(n[0], len(n[1:-1]), n[-1]))
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s269086426 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | S = input()
print(S[0] + string(len(S) - 2) + S[len(S)])
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s933606152 | Wrong Answer | p03635 | Input is given from Standard Input in the following format:
n m | a, *b, c = input()
print(a, len(b), c, sep="")
| Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of blocks in K-city.
* * * | s332371898 | Runtime Error | p03635 | Input is given from Standard Input in the following format:
n m | print((int(input())-1)*(int(input()-1)) | Statement
In _K-city_ , there are n streets running east-west, and m streets running
north-south. Each street running east-west and each street running north-south
cross each other. We will call the smallest area that is surrounded by four
streets a block. How many blocks there are in K-city? | [{"input": "3 4", "output": "6\n \n\nThere are six blocks, as shown below:\n\n\n\n* * *"}, {"input": "2 2", "output": "1\n \n\nThere are one block, as shown below:\n\n"}] |
Print the number of Product Days in a year in Takahashi Calender.
* * * | s511558626 | Runtime Error | p02927 | Input is given from Standard Input in the following format:
M D | # 二部グラフにできるのか
# ここからよ
# 実は奇サイクルを含まない=二部グラフとなる
# それぞれのレベルで奇サイクルかどうか
# 二部グラフを考えて残りでもどんどん二部グラフを考えるイメージ
# 最終的には1or2の状態で残る
N = int(input())
ans = [[0] * N for j in range(N)]
# nはvecの長さ
# 次の通路のレベル
def dfs(n, vec, level):
global ans
# print(vec)
# print(n)
l = vec[: n // 2]
r = vec[n // 2 :]
for i in l:
for j in r:
ans[i][j] = level
if len(l) > 1:
dfs(len(l), l, level + 1)
if len(r) > 1:
dfs(len(r), r, level + 1)
dfs(N, [i for i in range(N)], 1)
for i in range(N - 1):
a = []
for j in range(N):
if i < j:
a.append(str(ans[i][j]))
print(" ".join(a))
| Statement
Today is August 24, one of the five Product Days in a year.
A date m-d (m is the month, d is the date) is called a Product Day when d is a
two-digit number, and all of the following conditions are satisfied (here
d_{10} is the tens digit of the day and d_1 is the ones digit of the day):
* d_1 \geq 2
* d_{10} \geq 2
* d_1 \times d_{10} = m
Takahashi wants more Product Days, and he made a new calendar called Takahashi
Calendar where a year consists of M month from Month 1 to Month M, and each
month consists of D days from Day 1 to Day D.
In Takahashi Calendar, how many Product Days does a year have? | [{"input": "15 40", "output": "10\n \n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n * 4-22\n * 6-23\n * 6-32\n * 8-24\n * 9-33\n * 10-25\n * 12-26\n * 12-34\n * 14-27\n * 15-35\n\n* * *"}, {"input": "12 31", "output": "5\n \n\n* * *"}, {"input": "1 1", "output": "0"}] |
Print the number of Product Days in a year in Takahashi Calender.
* * * | s359064966 | Accepted | p02927 | Input is given from Standard Input in the following format:
M D | s = input().split()
m, d = int(s[0]), int(s[1])
n = 0
for i in range(d):
w = str(i + 1)
if len(w) == 2 and int(w[1]) > 1 and int(w[0]) > 1:
p = 1
for j in w:
p *= int(j)
if p <= m and p != 0:
n += 1
print(n)
| Statement
Today is August 24, one of the five Product Days in a year.
A date m-d (m is the month, d is the date) is called a Product Day when d is a
two-digit number, and all of the following conditions are satisfied (here
d_{10} is the tens digit of the day and d_1 is the ones digit of the day):
* d_1 \geq 2
* d_{10} \geq 2
* d_1 \times d_{10} = m
Takahashi wants more Product Days, and he made a new calendar called Takahashi
Calendar where a year consists of M month from Month 1 to Month M, and each
month consists of D days from Day 1 to Day D.
In Takahashi Calendar, how many Product Days does a year have? | [{"input": "15 40", "output": "10\n \n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n * 4-22\n * 6-23\n * 6-32\n * 8-24\n * 9-33\n * 10-25\n * 12-26\n * 12-34\n * 14-27\n * 15-35\n\n* * *"}, {"input": "12 31", "output": "5\n \n\n* * *"}, {"input": "1 1", "output": "0"}] |
Print the number of Product Days in a year in Takahashi Calender.
* * * | s752651308 | Runtime Error | p02927 | Input is given from Standard Input in the following format:
M D | a, b = input().strip()
print(a, b)
| Statement
Today is August 24, one of the five Product Days in a year.
A date m-d (m is the month, d is the date) is called a Product Day when d is a
two-digit number, and all of the following conditions are satisfied (here
d_{10} is the tens digit of the day and d_1 is the ones digit of the day):
* d_1 \geq 2
* d_{10} \geq 2
* d_1 \times d_{10} = m
Takahashi wants more Product Days, and he made a new calendar called Takahashi
Calendar where a year consists of M month from Month 1 to Month M, and each
month consists of D days from Day 1 to Day D.
In Takahashi Calendar, how many Product Days does a year have? | [{"input": "15 40", "output": "10\n \n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n * 4-22\n * 6-23\n * 6-32\n * 8-24\n * 9-33\n * 10-25\n * 12-26\n * 12-34\n * 14-27\n * 15-35\n\n* * *"}, {"input": "12 31", "output": "5\n \n\n* * *"}, {"input": "1 1", "output": "0"}] |
Print the number of Product Days in a year in Takahashi Calender.
* * * | s068147251 | Runtime Error | p02927 | Input is given from Standard Input in the following format:
M D | n, k = map(int, input().split())
l = list(map(int, input().split()))
mod = 10**9 + 7
a = 0
for i in range(n):
b = l[i]
t = (len([1 for m in l if m < b]) % mod) * (int((k - 1) % mod * k // 2) % mod) % mod
# print(i,b,t)
s = (len([1 for m in l[i:] if m < b]) % mod) * k % mod
# print(s)
a += (s + t) % mod
print(a % mod)
| Statement
Today is August 24, one of the five Product Days in a year.
A date m-d (m is the month, d is the date) is called a Product Day when d is a
two-digit number, and all of the following conditions are satisfied (here
d_{10} is the tens digit of the day and d_1 is the ones digit of the day):
* d_1 \geq 2
* d_{10} \geq 2
* d_1 \times d_{10} = m
Takahashi wants more Product Days, and he made a new calendar called Takahashi
Calendar where a year consists of M month from Month 1 to Month M, and each
month consists of D days from Day 1 to Day D.
In Takahashi Calendar, how many Product Days does a year have? | [{"input": "15 40", "output": "10\n \n\nThere are 10 Product Days in a year, as follows (m-d denotes Month m, Day d):\n\n * 4-22\n * 6-23\n * 6-32\n * 8-24\n * 9-33\n * 10-25\n * 12-26\n * 12-34\n * 14-27\n * 15-35\n\n* * *"}, {"input": "12 31", "output": "5\n \n\n* * *"}, {"input": "1 1", "output": "0"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s589052178 | Accepted | p03320 | Input is given from Standard Input in the following format:
K | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]
ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def S():
return input()
def pf(s):
return print(s, flush=True)
def main():
k = I()
a = set(list(range(1, 10)))
for i in range(1, 16):
for j in range(1, 20 * i):
a.add(int("{}{}".format(j, "9" * i)))
m = inf
for c in sorted(list(a))[::-1]:
t = 0
n = c
while n > 0:
t += n % 10
n //= 10
tm = c / t
if m < tm - eps:
a.remove(c)
else:
m = tm
l = sorted(list(a))
return "\n".join(map(str, l[:k]))
print(main())
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s986526747 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | # snuke numbers
K = int(input())
# S(x) == Mとなる xが存在するならば x=1y9999...99のパターんのみ
def optimize(M):
if 1 <= M <= 9:
return M
Left = M - 1
ans = 1
u, v = divmod(M - 1, 9)
if v == 0:
return int(str(ans) + "9" * u)
else:
if ans + v > 9:
return int(str(ans) + str(v) + "9" * u)
else:
return int(str(v + ans) + "9" * u)
Answer = []
Possible_answer = [(i, optimize(i), optimize(i) / i) for i in range(1, 1001)]
Possible_answer.sort(key=lambda x: x[-1])
for i in range(1000):
index, number = Possible_answer[i][0], Possible_answer[i][1]
should_be_added = True
for j in range(i):
if Possible_answer[j][1] > number:
should_be_added = False
break
if should_be_added:
Answer.append(number)
Answer.sort()
for x in Answer[:K]:
print(x)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s617530887 | Accepted | p03320 | Input is given from Standard Input in the following format:
K | def ii():
return int(input())
def lii():
return list(map(int, input().split(" ")))
def lvi(N):
l = []
for _ in range(N):
l.append(ii())
return l
def lv(N):
l = []
for _ in range(N):
l.append(input())
return l
def S(n):
return sum(map(int, str(n)))
def snuke(n):
return n / S(n)
def main():
K = ii()
snuke_list = list(range(1, 10))
for n in range(1, 17):
c = 1
while True:
if snuke(10**n * c - 1) < snuke(10**n * (c + 1) - 1):
if not 10**n * c - 1 in snuke_list:
snuke_list.append(10**n * c - 1)
c += 1
else:
break
snuke_list = sorted(snuke_list)
for i in range(K):
print(snuke_list[i])
if __name__ == "__main__":
main()
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s795178314 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | k = int(input())
sn_max = 1
div_max = 1
sn_t = 1
div_t = 1
cnt = 0
n = 0
for i in range(1, min(k + 1, 10)):
print(i)
n += 1
cnt += 1
n += 10
while cnt < k and n < 100:
n_str = list(str(n))
sn_t = sum(list(map(int, n_str)))
divn_t = n / sn_t
m = n + 10
m_str = list(str(m))
sm_t = sum(list(map(int, n_str)))
divm_t = m / sm_t
if divn_t <= divm_t:
print(n)
cnt += 1
n = n + 10
n = 99
while cnt < k:
n_str = list(str(n))
sn_t = sum(list(map(int, n_str)))
divn_t = n / sn_t
m = n + 100
m_str = list(str(m))
sm_t = sum(list(map(int, m_str)))
divm_t = m / sm_t
if divn_t <= divm_t:
print(n)
cnt += 1
n = n + 100
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s745862472 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | K = int(input())
k = 0
def is_snuke(n, first_non9):
n_copy = n
s_n = 0
for dig in range(0, 16):
s_n += n_copy % 10
n_copy //= 10
return n * (s_n + 1) <= (n + 10**first_non9) * s_n
check = {}
for first_non9 in range(0, 16):
base = (10**first_non9) - 1
for top in range(1, 10**9):
if k >= K:
import sys
sys.exit()
n = top * (10**first_non9) + base
if is_snuke(n, first_non9):
k += 1
if n not in check:
print(n)
check[n] = True
else:
break
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s165425085 | Accepted | p03320 | Input is given from Standard Input in the following format:
K | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return map(int, stdin.readline().split())
def li_():
return map(lambda x: int(x) - 1, stdin.readline().split())
def lf():
return map(float, stdin.readline().split())
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
def digit_sum(num: int, base: int) -> int:
if num < base:
return num
else:
return digit_sum(int(num / base), base) + (num % base)
def snuke(num: int):
return num / digit_sum(num, 10)
k = ni()
snuke_nums = [i for i in range(1, 10)]
res = 9
cur = 9
if k <= res:
for s in snuke_nums[:k]:
print(s)
else:
while res != k:
cur += 1
cands = []
for i in range(len(str(cur))):
cands.append(int(str(cur)[: -i - 1] + "9" * (i + 1)))
mi = float("inf")
for c in cands:
if snuke(c) < mi:
cur = c
mi = snuke(c)
snuke_nums.append(cur)
res += 1
for s in snuke_nums:
print(s)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s555578646 | Accepted | p03320 | Input is given from Standard Input in the following format:
K | K = int(input())
def snuke(N):
S = list(str(N))
SN = 0
for i in S:
SN += int(i)
return N / SN
def X(D, n):
temp = (n + 10 ** (D + 1)) // (10 ** (D + 1))
return 10 ** (D + 1) * temp - 1
L = [1]
k = 1
for i in range(1, K):
N = L[k - 1] + 1
x = X(0, N)
tmp = snuke(N)
ans = N
for d in range(len(str(N))):
x = X(d, N)
if snuke(x) < tmp:
tmp = snuke(x)
ans = x
L.append(ans)
k += 1
for i in L:
print(i)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s486533300 | Accepted | p03320 | Input is given from Standard Input in the following format:
K | def calc(n):
if n == 0:
return -1
s = 0
n_ = n
while n:
s += n % 10
n //= 10
return n_ / s
# res = []
# for i in range(1,10**6):
# res.append((i/sunuke(i), i))
# # print(i, i/sunuke(i))
# res.sort()
# max_i = 0
# ret = []
# for v, i in res:
# if i > max_i:
# max_i = i
# print(i, v)
# ret.append(i)
# print(ret)
k = int(input())
for i in range(1, min(9, k) + 1):
print(i)
cnt = min(9, k)
i = min(9, k)
d = 1
while cnt < k:
# print(i,d)
while calc(i + d) > calc(i + d * 10):
d *= 10
i += d
print(i)
cnt += 1
# vv = [30999,39999]
# for v in vv:
# print(v, v/sunuke(v), 10)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s474298081 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | a = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"19",
"29",
"39",
"49",
"59",
"69",
"79",
"89",
"99",
"199",
"299",
"399",
"499",
"599",
"699",
"799",
"899",
"999",
]
b = [
"1099",
"1199",
"1299",
"1399",
"1499",
"1599",
"1699",
"1799",
"1899",
"1999",
"2099",
"2199",
"2299",
"2399",
"2499",
"2599",
"2699",
"2799",
"2899",
"2999",
"3099",
"3199",
"3299",
"3399",
"3499",
"3599",
"3699",
"3799",
"3899",
"3999",
"4099",
"4199",
"4299",
"4399",
"4499",
"4599",
"4699",
"4799",
"4899",
"4999",
"5099",
"5199",
"5299",
"5399",
"5499",
"5599",
"5699",
"5799",
"5899",
"5999",
"6099",
"6199",
"6299",
"6399",
"6499",
"6599",
"6699",
"6799",
"6899",
"6999",
"7099",
"7199",
"7299",
"7399",
"7499",
"7599",
"7699",
"7799",
"7899",
"7999",
"8099",
"8199",
"8299",
"8399",
"8499",
"8599",
"8699",
"8799",
"8899",
"8999",
"9099",
"9199",
"9299",
"9399",
"9499",
"9599",
"9699",
"9799",
"9899",
"9999",
]
k = int(input())
if k <= 27:
for i in range(k):
print(a[i])
else:
for s in a:
print(s)
cnt = 28
num = 0
while True:
for i in range(90):
print(b[i] + "9" * num)
cnt += 1
if k < cnt:
break
num += 1
if k < cnt:
break
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s712337231 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | # buf = []
# for n in range(1000000, 2000000):
# s = str(n)
# t = sum(map(int, s))
# buf.append((n / t, n))
# buf.sort()
# tmp_max = 0
# for v, n in buf:
# if tmp_max > n:
# continue
# print(n, v)
# tmp_max = n
# n = 100000009999999
# print(n, n / sum(map(int, str(n))))
# n = 100000099999999
# print(n, n / sum(map(int, str(n))))
# n = 100000999999999
# print(n, n / sum(map(int, str(n))))
# n = 100009999999999
# print(n, n / sum(map(int, str(n))))
# n = 100099999999999
# print(n, n / sum(map(int, str(n))))
# n = 100999999999999
# print(n, n / sum(map(int, str(n))))
# n = 101999999999999
# print(n, n / sum(map(int, str(n))))
# n = 109999999999999
# print(n, n / sum(map(int, str(n))))
# n = 199999999999999
# print(n, n / sum(map(int, str(n))))
# print(*buf, sep='\n')
def get_value(n):
return int(n) / sum(map(int, n))
def solve(k):
d = 1
ret = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
while True:
for z in range(2, 0, -1):
t = d - z - 1
if t < 0:
continue
suffix = "9" * t
for i in range(1, 10):
a = str(i) + "0" * z + suffix
b = str(i) + "0" * (z - 1) + "9" + suffix
if get_value(a) <= get_value(b):
for j in range(10):
ret.append(str(i) + "0" * (z - 1) + str(j) + suffix)
elif z == 1:
ret.append(str(i) + "9" + suffix)
if len(ret) >= k:
return ret[:k]
d += 1
k = int(input())
print("\n".join(solve(k)))
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s017780643 | Runtime Error | p03320 | Input is given from Standard Input in the following format:
K | K = int(input())
sunuke = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000, 20000000000, 30000000000, 40000000000, 50000000000, 60000000000, 70000000000, 80000000000, 90000000000, 100000000000, 200000000000, 300000000000, 400000000000, 500000000000, 600000000000, 700000000000, 800000000000, 900000000000, 1000000000000, 2000000000000, 3000000000000, 4000000000000, 5000000000000, 6000000000000, 7000000000000, 8000000000000, 9000000000000, 10000000000000, 20000000000000, 30000000000000, 40000000000000, 50000000000000, 60000000000000, 70000000000000, 80000000000000, 90000000000000, 100000000000000, 200000000000000, 300000000000000, 400000000000000, 500000000000000, 600000000000000, 700000000000000, 800000000000000, 900000000000000]
for i in range(K)
print(sunuke[i])
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s045485692 | Runtime Error | p03320 | Input is given from Standard Input in the following format:
K | k = input()
n=1
if k =< 9:
for cnt in range(1,k+1):
print(cnt)
else:
for cnt in range(1,10):
print(cnt)
for cnt in range(19,19+10*(k-9),10):
print(cnt)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s940402812 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | k = int(input())
f = 1
for _ in range(k // 9):
for i in range(1, 10):
print(10 ** (f - 1) * (i + 1) - 1)
f += 1
for i in range(1, k % 9 + 1):
print(10 ** (f - 1) * (i + 1) - 1)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s627630403 | Runtime Error | p03320 | Input is given from Standard Input in the following format:
K | k = int(input())
n=1
i=19+10*(k-9)
if k =< 9:
for cnt in range(1,k+1):
print(cnt)
else:
for cnt in range(1,10):
print(cnt)
for cnt in range(19,i,10):
print(cnt)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s790341836 | Wrong Answer | p03320 | Input is given from Standard Input in the following format:
K | k = int(input())
ans = [0] * 10
if k < 10:
for i in range(1, k):
print(i)
if k >= 10:
for i in range(1, 10):
ans[i] = i
print(i)
k -= 9
i = 1
while k > 0:
ans[i] = ans[i] * 10 + 9
print(ans[i])
i += 1
if i == 10:
i = 1
k -= 1
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s900685855 | Runtime Error | p03320 | Input is given from Standard Input in the following format:
K | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll sum(ll x){
ll ans=0;
while(x>0) ans+=x%10,x/=10;
return ans;
}
vec ans;
int search(ll x){
if(x>pow(10,15)) return 0;
ll y=x,k=0,a;
while(y>0){
if(y%10!=9){
a=y%10;
break;
}
k++;
y/=10;
}
if(k==ll(log10(x))+1) ans.push_back(x),search(x+1);
else{
if(x<=sum(x)*ll(pow(10,k))) ans.push_back(x),search(x+pow(10,k));
else search(x+(9-a)*pow(10,k));
}
}
int main(){
ll k;
cin>>k;
search(1);
sort(all(ans));
rep(i,k) cout<<ans[i]<<"\n";
} | Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print K lines. The i-th line should contain the i-th smallest Snuke number.
* * * | s191006799 | Runtime Error | p03320 | Input is given from Standard Input in the following format:
K | ################################################################
##............................................................##
##........................######..............................##
##.........................#######............................##
##........................#######.............................##
##.......................#####..####..........................##
##.....................#####......#####.......................##
##....................#####.........#####.....................##
##..................#############....######...................##
##................#####....########....######.................##
##..............#####........####........#######..............##
##............#####................######..#########..........##
##..........#####............##############.#############.....##
##........####.....##############...#######...###############.##
##.....##............##########....######.......################
##..........................#####..#####......................##
##..........................####..#####.......................##
##..........................####.#####........................##
##..........................####.#####........................##
##.........................#####..............................##
##..........................###...............................##
##............................................................##
##............................................................##
##..................#########.................................##
##..............##############................................##
##...........############.....................................##
##....................####....................................##
##.....................########..................##...........##
##................##############...........############.......##
##.........################...#####...#####...##########......##
##..#######################....#######.........########.......##
##....########.....###########..######.........#######........##
##........#......#####.#######...######.......#######.........##
##.............######..####.......####################........##
##...........#####.....###........###################.........##
##........###..........###.........##.........................##
##....................####....................................##
##....................####....................................##
##.....................###....................................##
################################################################
if int(input()) != 10:
exit(1)
| Statement
Let S(n) denote the sum of the digits in the decimal notation of n. For
example, S(123) = 1 + 2 + 3 = 6.
We will call an integer n a **Snuke number** when, for all positive integers m
such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.
Given an integer K, list the K smallest Snuke numbers. | [{"input": "10", "output": "1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 19"}] |
Print the answer.
* * * | s169071151 | Runtime Error | p03770 | Input is given from Standard Input in the following format:
N X Y
c_1 w_1
:
c_N w_N | import sys
stdin = sys.stdin
def li():
return [int(x) for x in stdin.readline().split()]
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return [float(x) for x in stdin.readline().split()]
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(ns())
def nf():
return float(ns())
from itertools import accumulate
n, w = li()
wi, vi = li()
w0 = wi
v_list = [[0] for _ in range(4)]
v_list[0].append(vi)
for _ in range(n - 1):
wi, vi = li()
v_list[wi - w0].append(vi)
for i in range(4):
v_list[i].sort(reverse=True)
v_list[i] = list(accumulate(v_list[i]))
ans = 0
res = w
for w1 in range(len(v_list[0])):
if w - w0 * (w1) < 0:
pass
else:
res1 = w - w0 * (w1)
ans1 = v_list[0][w1]
ans = max(ans, ans1)
for w2 in range(len(v_list[1])):
if res1 - (w0 + 1) * (w2) < 0:
pass
else:
res2 = res1 - (w0 + 1) * (w2)
ans2 = ans1 + v_list[1][w2]
ans = max(ans, ans2)
for w3 in range(len(v_list[2])):
if res2 - (w0 + 2) * (w3) < 0:
pass
else:
res3 = res2 - (w0 + 2) * (w3)
ans3 = ans2 + v_list[2][w3]
ans = max(ans, ans3)
for w4 in range(len(v_list[3])):
if res3 - (w0 + 3) * (w4) < 0:
pass
else:
res4 = res3 - (w0 + 3) * (w4)
ans4 = ans3 + v_list[3][w4]
ans = max(ans, ans4)
print(ans)
| Statement
Snuke arranged N colorful balls in a row. The i-th ball from the left has
color c_i and weight w_i.
He can rearrange the balls by performing the following two operations any
number of times, in any order:
* Operation 1: Select two balls with the same color. If the total weight of these balls is at most X, swap the positions of these balls.
* Operation 2: Select two balls with different colors. If the total weight of these balls is at most Y, swap the positions of these balls.
How many different sequences of colors of balls can be obtained? Find the
count modulo 10^9 + 7. | [{"input": "4 7 3\n 3 2\n 4 3\n 2 1\n 4 4", "output": "2\n \n\n * The sequence of colors (2,4,3,4) can be obtained by swapping the positions of the first and third balls by operation 2.\n * It is also possible to swap the positions of the second and fourth balls by operation 1, but it does not affect the sequence of colors.\n\n* * *"}, {"input": "1 1 1\n 1 1", "output": "1\n \n\n* * *"}, {"input": "21 77 68\n 16 73\n 16 99\n 19 66\n 2 87\n 2 16\n 7 17\n 10 36\n 10 68\n 2 38\n 10 74\n 13 55\n 21 21\n 3 7\n 12 41\n 13 88\n 18 6\n 2 12\n 13 87\n 1 9\n 2 27\n 13 15", "output": "129729600"}] |
Print the answer.
* * * | s676147832 | Accepted | p03770 | Input is given from Standard Input in the following format:
N X Y
c_1 w_1
:
c_N w_N | import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
MOD = 10**9 + 7
N, X, Y = map(int, readline().split())
CW = (tuple(int(x) for x in line.split()) for line in readlines())
C_to_W = [[] for _ in range(N + 1)]
for c, w in CW:
C_to_W[c].append(w)
for c in range(N + 1):
C_to_W[c].sort()
C_to_W.sort()
C_to_W = [x for x in C_to_W if x]
min_wt = C_to_W[0][0]
C_to_W = [x for x in C_to_W if x[0] + min_wt <= Y]
if len(C_to_W) <= 1:
print(1)
exit()
comp_size = [0] * (len(C_to_W))
for x in C_to_W[0]:
if x + C_to_W[0][0] <= X or x + C_to_W[1][0] <= Y:
comp_size[0] += 1
for i, arr in enumerate(C_to_W[1:], 1):
for x in arr:
if x + min_wt <= Y or x + arr[0] <= X:
comp_size[i] += 1
fact = [1] * (N + 1)
for i in range(1, N + 1):
fact[i] = fact[i - 1] * i % MOD
num = fact[sum(comp_size)]
den = 1
for x in comp_size:
den *= fact[x]
den %= MOD
answer = num * pow(den, MOD - 2, MOD) % MOD
print(answer)
| Statement
Snuke arranged N colorful balls in a row. The i-th ball from the left has
color c_i and weight w_i.
He can rearrange the balls by performing the following two operations any
number of times, in any order:
* Operation 1: Select two balls with the same color. If the total weight of these balls is at most X, swap the positions of these balls.
* Operation 2: Select two balls with different colors. If the total weight of these balls is at most Y, swap the positions of these balls.
How many different sequences of colors of balls can be obtained? Find the
count modulo 10^9 + 7. | [{"input": "4 7 3\n 3 2\n 4 3\n 2 1\n 4 4", "output": "2\n \n\n * The sequence of colors (2,4,3,4) can be obtained by swapping the positions of the first and third balls by operation 2.\n * It is also possible to swap the positions of the second and fourth balls by operation 1, but it does not affect the sequence of colors.\n\n* * *"}, {"input": "1 1 1\n 1 1", "output": "1\n \n\n* * *"}, {"input": "21 77 68\n 16 73\n 16 99\n 19 66\n 2 87\n 2 16\n 7 17\n 10 36\n 10 68\n 2 38\n 10 74\n 13 55\n 21 21\n 3 7\n 12 41\n 13 88\n 18 6\n 2 12\n 13 87\n 1 9\n 2 27\n 13 15", "output": "129729600"}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s262380274 | Runtime Error | p02862 | Input is given from Standard Input in the following format:
X Y | x, y = int(input()), int(input())
xans = x // 2
ans, m, j, k = 0, 1, 1, 1
for i in range(xans):
if y == (xans - i) * 2 + i:
m = 1
for l in range(1, i + 1):
m *= l
k = 1
for l in range(1, xans - i + 1):
k *= l
j = 1
for l in range(1, xans + 1):
j *= l
ans += j / m / k
if y == 2 * x:
ans += 1
ans = ans // 1
print(int(ans % 1000000007))
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s040385995 | Accepted | p02862 | Input is given from Standard Input in the following format:
X Y | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
class ModTools:
"""階乗たくさん使う時用のテーブル準備"""
def __init__(self, MAX, MOD):
"""MAX:階乗に使う数値の最大以上まで作る"""
MAX += 1
self.MAX = MAX
self.MOD = MOD
# 階乗テーブル
factorial = [1] * MAX
factorial[0] = factorial[1] = 1
for i in range(2, MAX):
factorial[i] = factorial[i - 1] * i % MOD
# 階乗の逆元テーブル
inverse = [1] * MAX
# powに第三引数入れると冪乗のmod付計算を高速にやってくれる
inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD)
for i in range(MAX - 2, 0, -1):
# 最後から戻っていくこのループならMAX回powするより処理が速い
inverse[i] = inverse[i + 1] * (i + 1) % MOD
self.fact = factorial
self.inv = inverse
def nCr(self, n, r):
"""組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく)"""
if n < r:
return 0
# 10C7 = 10C3
r = min(r, n - r)
# 分子の計算
numerator = self.fact[n]
# 分母の計算
denominator = self.inv[r] * self.inv[n - r] % self.MOD
return numerator * denominator % self.MOD
def nPr(self, n, r):
"""順列"""
if n < r:
return 0
return self.fact[n] * self.inv[n - r] % self.MOD
def nHr(self, n, r):
"""重複組み合わせ"""
# r個選ぶところにN-1個の仕切りを入れる
return self.nCr(r + n - 1, r)
x, y = MAP()
x, y = min(x, y), max(x, y)
sm = x + y
if sm % 3 != 0:
print(0)
exit()
if y - x > sm // 3:
print(0)
exit()
# 連立方程式から式変形
a = (2 * y - x) // 3
b = (2 * x - y) // 3
mt = ModTools(a + b, MOD)
print(mt.nCr(a + b, a))
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s977840375 | Runtime Error | p02862 | Input is given from Standard Input in the following format:
X Y | hash_no = 10**9 + 7
x, y = map(int, input().split())
counter = 0
def move(x, y, X, Y):
global counter
if x > X:
return
if y > Y:
return
if (x == X) and (y == Y):
counter += 1
return
move(x + 1, y + 2, X, Y)
move(x + 2, y + 1, X, Y)
move(0, 0, x, y)
print(counter / hash_no)
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s899625248 | Wrong Answer | p02862 | Input is given from Standard Input in the following format:
X Y | X, Y = map(int, input().split())
ans = 0
if Y // 2 > X:
na_max = X + 1
else:
na_max = Y // 2 + 1
if X // 2 > Y:
nb_max = Y + 1
else:
nb_max = X // 2 + 1
if X % 2 == 1 and Y % 2 == 1:
for na in range(1, na_max, 2):
for nb in range(1, nb_max, 2):
if na + 2 * nb == X and 2 * na + nb == Y:
ans += 1
print(ans % (10**9 + 7))
elif X % 2 == 1 and Y % 2 == 0:
for na in range(1, na_max, 2):
for nb in range(0, nb_max, 2):
if na + 2 * nb == X and 2 * na + nb == Y:
ans += 1
print(ans % (10**9 + 7))
elif X % 2 == 0 and Y % 2 == 1:
for na in range(0, na_max, 2):
for nb in range(1, nb_max, 2):
if na + 2 * nb == X and 2 * na + nb == Y:
ans += 1
print(ans % (10**9 + 7))
elif X % 2 == 0 and Y % 2 == 0:
for na in range(0, na_max, 2):
for nb in range(0, nb_max, 2):
if na + 2 * nb == X and 2 * na + nb == Y:
ans += 1
print(ans % (10**9 + 7))
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s826434962 | Wrong Answer | p02862 | Input is given from Standard Input in the following format:
X Y | x, y = map(int, input().split())
cnt = 0
for i in range(0, x + 1):
for j in range(0, y + 1):
if (i * 1 + j * 2) == x and (i * 2 + j * 1) == y:
cnt += 1
print(cnt * 2)
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo
10^9 + 7.
* * * | s008220461 | Wrong Answer | p02862 | Input is given from Standard Input in the following format:
X Y | # Python3 code to find minimum steps to reach
# to specific cell in minimum moves by Knight
class cell:
def __init__(self, x=0, y=0, dist=0):
self.x = x
self.y = y
self.dist = dist
# checks whether given position is
# inside the board
def isInside(x, y, N):
if x >= 1 and x <= N and y >= 1 and y <= N:
return True
return False
# Method returns minimum step to reach
# target position
def minStepToReachTarget(knightpos, targetpos, N):
# all possible movments for the knight
dx = [2, 2, 1, 1]
dy = [1, 1, 2, 2]
queue = []
# push starting position of knight
# with 0 distance
queue.append(cell(knightpos[0], knightpos[1], 0))
# make all cell unvisited
visited = [[False for i in range(N + 1)] for j in range(N + 1)]
# visit starting state
visited[knightpos[0]][knightpos[1]] = True
# loop untill we have one element in queue
while len(queue) > 0:
t = queue[0]
queue.pop(0)
# if current cell is equal to target
# cell, return its distance
if t.x == targetpos[0] and t.y == targetpos[1]:
return t.dist
# iterate for all reachable states
for i in range(4):
x = t.x + dx[i]
y = t.y + dy[i]
if isInside(x, y, N) and not visited[x][y]:
visited[x][y] = True
queue.append(cell(x, y, t.dist + 1))
# Driver Code
if __name__ == "__main__":
N = 1000
targetpos = list(map(int, input().split()))
knightpos = [0, 0]
(
print(int(minStepToReachTarget(knightpos, targetpos, N) % 1e7))
if minStepToReachTarget(knightpos, targetpos, N) is not None
else print(0)
)
# This code is contributed by
# Kaustav kumar Chanda
| Statement
There is a knight - the chess piece - at the origin (0, 0) of a two-
dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2)
or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7. | [{"input": "3 3", "output": "2\n \n\nThere are two ways: (0,0) \\to (1,2) \\to (3,3) and (0,0) \\to (2,1) \\to (3,3).\n\n* * *"}, {"input": "2 2", "output": "0\n \n\nThe knight cannot reach (2,2).\n\n* * *"}, {"input": "999999 999999", "output": "151840682\n \n\nPrint the number of ways modulo 10^9 + 7."}] |
Print the number of the possible values for S after the M operations, modulo
1000000007.
* * * | s190019081 | Runtime Error | p03859 | The input is given from Standard Input in the following format:
N M
S
l_1 r_1
:
l_M r_M | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n + 1)]
self.rank = [0] * (n + 1)
self.size = [1] * (n + 1)
# 譬ケ繧呈、懃エ「縺吶k髢「謨ー
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.find(self.par[x])
# 邨仙粋(unite)縺吶k髢「謨ー
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.rank[x] < self.rank[y]:
self.par[x] = y
self.size[y] += self.size[x]
else:
self.par[y] = x
self.size[x] += self.size[y]
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
# 蜷後§繧ー繝ォ繝シ繝励↓螻槭☆繧九°繧貞愛螳壹☆繧矩未謨ー
def same_check(self, x, y):
return self.find(x) == self.find(y)
# 隕∫エ縺悟ア槭☆繧区惠縺ョ豺ア縺輔r霑斐☆髢「謨ー
def get_depth(self, x):
return self.rank[self.find(x)]
# 隕∫エ縺悟ア槭☆繧区惠縺ョ繧オ繧、繧コ繧定ソ斐☆髢「謨ー
def get_size(self, x):
return self.size[self.find(x)]
# 繧ー繝ォ繝シ繝玲焚繧定ソ斐☆髢「謨ー
def group_sum(self):
c = 0
for i in range(len(self.par)):
if self.find(i) == i:
c += 1
return c
if __name__ == "__main__":
N, K, L = map(int, input().split())
uf = UnionFind(N)
for i in range(K):
p, q = [int(i) for i in input().split()]
uf.unite(p, q)
ans = [1] * N
for i in range(L):
r, s = [int(i) for i in input().split()]
if uf.same_check(r, s):
ans[r - 1] += 1
ans[s - 1] += 1
print(*ans)
| Statement
There is a string S of length N consisting of characters `0` and `1`. You will
perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i is non-decreasing.
How many values are possible for S after the M operations, modulo 1000000007(=
10^9+7)? | [{"input": "5 2\n 01001\n 2 4\n 3 5", "output": "6\n \n\nAfter the first operation, S can be one of the following three: `01001`,\n`00101` and `00011`.\n\nAfter the second operation, S can be one of the following six: `01100`,\n`01010`, `01001`, `00011`, `00101` and `00110`.\n\n* * *"}, {"input": "9 3\n 110111110\n 1 4\n 4 6\n 6 9", "output": "26\n \n\n* * *"}, {"input": "11 6\n 00101000110\n 2 4\n 2 3\n 4 7\n 5 6\n 6 10\n 10 11", "output": "143"}] |
Print the number of the possible values for S after the M operations, modulo
1000000007.
* * * | s941355240 | Runtime Error | p03859 | The input is given from Standard Input in the following format:
N M
S
l_1 r_1
:
l_M r_M | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
int add(int x, int y)
{
x += y;
if (x >= MOD) return x - MOD;
return x;
}
int sub(int x, int y)
{
x -= y;
if (x < 0) return x + MOD;
return x;
}
int mult(int x, int y)
{
return ((ll)x * y) % MOD;
}
const int N = 3030;
int n;
char s[N];
int a[N];
int b[N];
int dp[N][N];
int C[N][N];
void read()
{
int m;
scanf("%d%d", &n, &m);
scanf(" %s ", s);
for (int i = 0; i < n; i++)
a[i] = (int)(s[i] - '0');
for (int i = 0; i < n; i++)
b[i] = i + 1;
while(m--)
{
int l, r;
scanf("%d%d", &l, &r);
l--;
b[l] = max(b[l], r);
}
for (int i = 1; i < n; i++)
b[i] = max(b[i], b[i - 1]);
}
int main()
{
read();
for (int i = 0; i < N; i++)
C[i][0] = C[i][i] = 1;
for (int i = 1; i < N; i++)
for (int j = 1; j < i; j++)
C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
dp[0][0] = 1;
int cur = 0;
for (int i = 0; i < n; i++)
{
int willAdd = 0;
while(cur < b[i])
{
willAdd += a[cur];
cur++;
}
for (int x = 0; x <= n; x++)
{
if (dp[i][x] == 0) continue;
int y = x + willAdd;
if (y != 0)
dp[i + 1][y - 1] = add(dp[i + 1][y - 1], dp[i][x]);
if (y != cur - i)
dp[i + 1][y] = add(dp[i + 1][y], dp[i][x]);
}
}
printf("%d\n", dp[n][0]);
return 0;
} | Statement
There is a string S of length N consisting of characters `0` and `1`. You will
perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i is non-decreasing.
How many values are possible for S after the M operations, modulo 1000000007(=
10^9+7)? | [{"input": "5 2\n 01001\n 2 4\n 3 5", "output": "6\n \n\nAfter the first operation, S can be one of the following three: `01001`,\n`00101` and `00011`.\n\nAfter the second operation, S can be one of the following six: `01100`,\n`01010`, `01001`, `00011`, `00101` and `00110`.\n\n* * *"}, {"input": "9 3\n 110111110\n 1 4\n 4 6\n 6 9", "output": "26\n \n\n* * *"}, {"input": "11 6\n 00101000110\n 2 4\n 2 3\n 4 7\n 5 6\n 6 10\n 10 11", "output": "143"}] |
Print the number of the possible values for S after the M operations, modulo
1000000007.
* * * | s281819192 | Wrong Answer | p03859 | The input is given from Standard Input in the following format:
N M
S
l_1 r_1
:
l_M r_M | #!/usr/bin/env python3
M = 10**9 + 7
def solve(n, m, s, lst):
cnt = [0] * n
t = 0
for i in range(n):
if s[i] == "1":
t += 1
cnt[i] = t
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
r = 0
j = 0
for i in range(n):
while j < m:
lj, rj = lst[j]
if lj <= i:
r = max(r, rj)
j += 1
else:
break
if r <= i:
c = cnt[i]
if 0 < c:
dp[i + 1][cnt[i]] = dp[i][c] + dp[i][c - 1]
else:
dp[i + 1][0] = dp[i][0]
else:
for k in range(max(0, cnt[r] - r + i), min(i + 1, cnt[r]) + 1):
if 0 < k:
dp[i + 1][k] = dp[i][k] + dp[i][k - 1]
else:
dp[i + 1][0] = dp[i][0]
return dp[n][cnt[n - 1]]
def main():
n, m = input().split()
n = int(n)
m = int(m)
s = input()
lst = []
for _ in range(m):
l, r = input().split()
l = int(l) - 1
r = int(r) - 1
lst.append((l, r))
print(solve(n, m, s, lst))
if __name__ == "__main__":
main()
| Statement
There is a string S of length N consisting of characters `0` and `1`. You will
perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i is non-decreasing.
How many values are possible for S after the M operations, modulo 1000000007(=
10^9+7)? | [{"input": "5 2\n 01001\n 2 4\n 3 5", "output": "6\n \n\nAfter the first operation, S can be one of the following three: `01001`,\n`00101` and `00011`.\n\nAfter the second operation, S can be one of the following six: `01100`,\n`01010`, `01001`, `00011`, `00101` and `00110`.\n\n* * *"}, {"input": "9 3\n 110111110\n 1 4\n 4 6\n 6 9", "output": "26\n \n\n* * *"}, {"input": "11 6\n 00101000110\n 2 4\n 2 3\n 4 7\n 5 6\n 6 10\n 10 11", "output": "143"}] |
Print the number of the possible values for S after the M operations, modulo
1000000007.
* * * | s270312431 | Wrong Answer | p03859 | The input is given from Standard Input in the following format:
N M
S
l_1 r_1
:
l_M r_M | # coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n, m = map(int, readline().split())
s = input()
mp = map(int, read().split())
r = [0] * n
for i, j in zip(mp, mp):
if r[i - 1] < j - 1:
r[i - 1] = j - 1
for i in range(1, n):
if r[i] < r[i - 1]:
r[i] = r[i - 1]
zero = [0] * n
for i in range(n):
zero[i] = zero[i - 1]
if s[i] == "0":
zero[i] += 1
# print(r)
# print(s)
# print(zero)
MOD = 10**9 + 7
dp = [0] * n
dp[0] = 1
for i in range(n):
L = max(zero[r[i]] + i - r[i], 0)
R = min(zero[r[i]], i + 1)
ndp = [0] * n
for i in range(L, R + 1):
if i:
ndp[i] += dp[i - 1]
ndp[i] += dp[i]
ndp[i] %= MOD
dp = ndp
# print(L,R,r[i],zero[r[i]],dp)
print(sum(dp) % MOD)
| Statement
There is a string S of length N consisting of characters `0` and `1`. You will
perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i is non-decreasing.
How many values are possible for S after the M operations, modulo 1000000007(=
10^9+7)? | [{"input": "5 2\n 01001\n 2 4\n 3 5", "output": "6\n \n\nAfter the first operation, S can be one of the following three: `01001`,\n`00101` and `00011`.\n\nAfter the second operation, S can be one of the following six: `01100`,\n`01010`, `01001`, `00011`, `00101` and `00110`.\n\n* * *"}, {"input": "9 3\n 110111110\n 1 4\n 4 6\n 6 9", "output": "26\n \n\n* * *"}, {"input": "11 6\n 00101000110\n 2 4\n 2 3\n 4 7\n 5 6\n 6 10\n 10 11", "output": "143"}] |
Print the maximum possible sum of the integers written on the picked cards.
* * * | s398089165 | Wrong Answer | p02931 | Input is given from Standard Input in the following format:
N H W
R_1 C_1 A_1
R_2 C_2 A_2
\vdots
R_N C_N A_N | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import operator
N, H, W = map(int, readline().split())
RCA = [int(x) for x in read().split()]
it = iter(RCA)
RCA = sorted(zip(it, it, it), key=operator.itemgetter(2), reverse=True)
| Statement
There are N cards placed on a grid with H rows and W columns of squares.
The i-th card has an integer A_i written on it, and it is placed on the square
at the R_i-th row from the top and the C_i-th column from the left.
Multiple cards may be placed on the same square.
You will first pick up at most one card from each row.
Then, you will pick up at most one card from each column.
Find the maximum possible sum of the integers written on the picked cards. | [{"input": "6 2 2\n 2 2 2\n 1 1 8\n 1 1 5\n 1 2 9\n 1 2 7\n 2 1 4", "output": "28\n \n\nThe sum of the integers written on the picked cards will be 28, the maximum\nvalue possible, if you pick up cards as follows:\n\n * Pick up the fourth card from the first row.\n * Pick up the sixth card from the second row.\n * Pick up the second card from the first column.\n * Pick up the fifth card from the second column.\n\n* * *"}, {"input": "13 5 6\n 1 3 35902\n 4 6 19698\n 4 6 73389\n 3 6 3031\n 3 1 4771\n 1 4 4784\n 2 1 36357\n 2 1 24830\n 5 6 50219\n 4 6 22645\n 1 2 30739\n 1 4 68417\n 1 5 78537", "output": "430590\n \n\n* * *"}, {"input": "1 100000 100000\n 1 1 1", "output": "1"}] |
Print the maximum possible sum of the integers written on the picked cards.
* * * | s975883628 | Wrong Answer | p02931 | Input is given from Standard Input in the following format:
N H W
R_1 C_1 A_1
R_2 C_2 A_2
\vdots
R_N C_N A_N | N, H, W = map(int, input().split())
r = []
c = []
w = []
tmp = []
for num in range(N):
a1, a2, a3 = map(int, input().split())
r.append(a1)
c.append(a2)
w.append(a3)
count = 0
for num in range(N):
tmp_list = [u for s, t, u in zip(r, c, w) if s == num]
if tmp_list == []:
continue
max_r = max(tmp_list)
if tmp_list.count(max_r) > 1:
indexes = [i for i, u in enumerate(tmp_list) if u == max_r]
cs = [t for i, t in enumerate(c) if i in indexes]
ws = [u for s, t, u in zip(r, c, w) if t in cs and s == num]
index_1 = ws.index(max(ws))
else:
index_1 = tmp_list.index(max_r)
w[index_1] = 0
count += max_r
tmp_r = r
r = c
c = tmp_r
for num in range(N):
tmp_list = [u for s, t, u in zip(r, c, w) if s == num]
if tmp_list == []:
continue
max_r = max(tmp_list)
if tmp_list.count(max_r) > 1:
indexes = [i for i, u in enumerate(tmp_list) if u == max_r]
cs = [t for i, t in enumerate(c) if i in indexes]
ws = [u for s, t, u in zip(r, c, w) if t in cs and s == num]
index_1 = ws.index(max(ws))
else:
index_1 = tmp_list.index(max_r)
w[index_1] = 0
count += max_r
print(count)
| Statement
There are N cards placed on a grid with H rows and W columns of squares.
The i-th card has an integer A_i written on it, and it is placed on the square
at the R_i-th row from the top and the C_i-th column from the left.
Multiple cards may be placed on the same square.
You will first pick up at most one card from each row.
Then, you will pick up at most one card from each column.
Find the maximum possible sum of the integers written on the picked cards. | [{"input": "6 2 2\n 2 2 2\n 1 1 8\n 1 1 5\n 1 2 9\n 1 2 7\n 2 1 4", "output": "28\n \n\nThe sum of the integers written on the picked cards will be 28, the maximum\nvalue possible, if you pick up cards as follows:\n\n * Pick up the fourth card from the first row.\n * Pick up the sixth card from the second row.\n * Pick up the second card from the first column.\n * Pick up the fifth card from the second column.\n\n* * *"}, {"input": "13 5 6\n 1 3 35902\n 4 6 19698\n 4 6 73389\n 3 6 3031\n 3 1 4771\n 1 4 4784\n 2 1 36357\n 2 1 24830\n 5 6 50219\n 4 6 22645\n 1 2 30739\n 1 4 68417\n 1 5 78537", "output": "430590\n \n\n* * *"}, {"input": "1 100000 100000\n 1 1 1", "output": "1"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s192489599 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
print(min(abs(x-a),abs(x-b)) | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s277375182 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b)) | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s520962794 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | X, A, B = map(int, input().split())
print(min(abs(X-A), abs(B-X)) | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s933575518 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x, a, b = map(int, input().split())
print((abs(x-a) > abs(x-b)) ? "A" : "B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s779074687 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | # ABC071-C
N = int(input())
A_list = list(map(int, input().split()))
A_set = set(A_list)
A_set = sorted(A_set, reverse=True)
side_list = [0, 0]
for i in range(len(A_set)): # 大きい順に取っていき,リストで個数を確認する
if len(side_list) >= 4:
break
count = A_list.count(A_set[i]) # リストの個数を確認
if count == 2 or count == 3:
side_list.append(A_set[i])
if count >= 4:
side_list.append(A_set[i])
side_list.append(A_set[i])
side_list.sort(reverse=True)
print(side_list[0] * side_list[1])
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s977761787 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | input()
param_list = sorted([int(v) for v in input().split(" ")], reverse=True)
result = 0
duplicate_param = 0
count = 1
for v in param_list:
if v == duplicate_param:
if count == 1:
result = v
duplicate_param = 0
else:
result *= v
print(result)
break
count += 1
else:
duplicate_param = v
if result == 0:
print(0)
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s137468807 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
y=abs(x-a)
z=abs(b-x)
if y<z:
print('A')
else:
print('B')
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s856775093 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | a,b,c=(int(x) for x in input().split())
if a < b < c:
print( 'A' )
elif a < c < b:
print( 'A' )
elif b < a < c:
print( 'B' )
elif b < c < a:
print( 'B' )
elif c < a < b:
print( 'C' )
elif c < b < a | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s504775276 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | n = int(input())
a = list(map(int, input().split(" ")))
x = 0
y = 0
a.sort()
a.reverse()
for i in range(len(a) - 1):
if a[i] == a[i + 1]:
x = a[i]
p = i + 1
break
if x != 0:
for i in range((p + 1), len(a) - 1):
if a[i] == a[i + 1]:
y = a[i]
break
print(x * y)
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s433132169 | Accepted | p03623 | Input is given from Standard Input in the following format:
x a b | #!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, randint, randrange, shuffle, sample
# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict # subclass of dict. defaultdict(facroty)
# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce # reduce(f, iter[, init])
# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate # accumulate(iter[, f])
# from operator import itemgetter # itemgetter(1), itemgetter('key')
# from fractions import gcd # for Python 3.4 (previous contest @AtCoder)
def main():
mod = 1000000007 # 10^9+7
inf = float("inf") # sys.float_info.max = 1.79...e+308
# inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19
sys.setrecursionlimit(10**6) # 1000 -> 1000000
def input():
return sys.stdin.readline().rstrip()
def ii():
return int(input())
def mi():
return map(int, input().split())
def mi_0():
return map(lambda x: int(x) - 1, input().split())
def lmi():
return list(map(int, input().split()))
def lmi_0():
return list(map(lambda x: int(x) - 1, input().split()))
def li():
return list(input())
x, a, b = mi()
print("A") if abs(x - a) < abs(x - b) else print("B")
if __name__ == "__main__":
main()
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s539877538 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Math;
namespace ConsoleApp15
{
class Class404
{
static void Main()
{
var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
int a = Abs(r[0] - r[1]);
int b = Abs(r[0] - r[2]);
if (a > b)
{
Console.WriteLine("B");
}
else
{
Console.WriteLine("A");
}
}
}
}
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s652686561 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | def read_line(*types):
return [f(a) for a, f in zip(input().split(), types)]
(n,) = read_line(int)
m = 1000000007
domino = []
domino.append(input())
domino.append(input())
# print(domino[0])
# print(domino[1])
def compress(line):
x = [line[0]]
for c in line[1:]:
if x[-1] != c:
x.append(c)
return x
domino[0] = compress(domino[0])
domino[1] = compress(domino[1])
xs = []
for i in range(len(domino[0])):
xs.append(domino[0][i] != domino[1][i])
# print(xs)
patterns = None
if xs[0]:
patterns = 6
else:
patterns = 3
lastX = xs[0]
for x in xs[1:]:
if x:
# T -> T
if lastX:
patterns *= 3
else:
# F -> T
patterns *= 2
else:
# T -> F
if lastX:
patterns *= 1
else: # F -> F
patterns *= 2
lastX = x
print(patterns % m)
# T -> T
# 6 * 4 = 24
# 0|1120
# 1|2002
# 0
# 2
# 1
# 0
# 1
# 2
# 2
# 0
# 2
# 1
# F -> T
# 3 * 2 = 6
# 0|12
# 0|21
#
# 1|02
# 1|20
#
# 2|10
# 2|01
# T -> F
# 6 * 1 = 6
# 0|2
# 1|2
# 0|1
# 2|1
# 1|2
# 0|2
# 1|0
# 2|0
# 2|1
# 0|1
# 2|0
# 1|0
# F -> F
# 3 * 2 = 6
# 0 | 12
# 1 | 02
# 2 | 01
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s109538479 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | a, b, c = map(int,input().split())
R = int(|a-b|)
E = int(|a-c|)
if R > E:
print("B")
else:
print("A") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s843027292 | Accepted | p03623 | Input is given from Standard Input in the following format:
x a b | def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
def zeros(n):
return [0] * n
INF = 10**18
class Debug:
def __init__(self):
self.debug = True
def off(self):
self.debug = False
def dmp(self, x, cmt=""):
if self.debug:
if cmt != "":
w = cmt + ": " + str(x)
else:
w = str(x)
print(w)
return x
def prob():
d = Debug()
d.off()
X, A, B = getIntList()
if abs(X - A) < abs(X - B):
return "A"
else:
return "B"
ans = prob()
print(ans)
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s477615453 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
if abs(x-a)>=abs(x-b)
print('B')
else:
print('A')
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s827461749 | Wrong Answer | p03623 | Input is given from Standard Input in the following format:
x a b | x = sorted(set(chr(97 + i) for i in range(26)) - set(input()))
print("None" if not x else x[0])
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s301829677 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=[int(s) for s in input().split()]
if abs(a-x)<abs(b-x):
print('A'):
else:
print('B') | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s408090305 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int, input()split())
if abs(x-b) > abs(x-a):
print('A')
else:
print('B') | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s549661944 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b)
print('A')
else:
print('B') | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s617403496 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
print('A'):
else:
print('B')
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s443961143 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
print("A")
else print("B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s651001019 | Wrong Answer | p03623 | Input is given from Standard Input in the following format:
x a b | n, a, b = map(int, input().split())
print(min(abs(n - a), abs(n - b)))
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s101133407 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | a, b, c = map(int,input().split())
if |a-b| > |a-c|:
print("B")
else:
print("A") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s967206137 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x, a, b = list(map(int, input().split())
print("a" if abs(x-a) < abs(x-b) else "b") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s264832838 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | a, b, c = input()
print("YNeos"[a != c :: 2])
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s136053590 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | L=list(map(int,input().split()))
A=L[0]-L[1]
B=L[0]-L[2]
if min(A,B)=A:
print("A")
else:
print("B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s906321676 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b = map(int,input().split())
A = abs(x-a)
B = abs(x-b)
if A<B:
print("A")
else;
print("B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s058614016 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x, a, b = map(int(input())
A = abs(x-a)
B = abs(x-b)
if A < B:
print("A")
else:
print("B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s051928779 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x, a, b = map(int, input().split())
if (abs(x - a) < abs(x - b):
print('A')
else:
print('B') | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s651599802 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | S = input()
A = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
B = [0]*26
flag = -1
for i in range(len(S)):
for j in range(len(A)):
if S[i] == A[j]:
B[j] += 1
break
if i == len(S)
break
for k in range(B):
if B[k] == 0
print(A[k])
flag = 1
break
if flag == -1:
print("none") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s833291144 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | #x a bを設定する
x,a,b = map(int,input().split())
#x からaまでの距離とxからbまでの距離を計算する
a_distant = (a - x)^2
b_distant = (b - x)^2
#aまでとbまでを比較して短い方を出力する
if a_distant > b_distant:
print("B")
if b_distant > a_distant
print("A")
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s315489505 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x, a, b = map(int, input().split(' '))
dist_atox = abs(a-x)
dist_btox = abs(b-x)
y = dist_atox - dist_btox
print("A" if dist_atox < dist_btox else "B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s502699033 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | S = list(input())
# 重要:アルファベットの配列を生成
alphabets = [chr(ord('a') + i) for i in range(26)]
# 除外文字を配列に入れる
excludeS = []
for i in range(len(alphabets)):
if alphabets[i] not in S:
excludeS.append(alphabets[i])
flag = False
if alphabets[i] == 'Z'
flag = True
else:
flag = True
if flag:
print('None')
else:
# 辞書順に並び変えて一番小さい文字を求める
sortedExcludeS = sorted(excludeS)
minExcludeS = min(sortedExcludeS)
print(minExcludeS)
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s096990404 | Wrong Answer | p03623 | Input is given from Standard Input in the following format:
x a b | s = list(input())
a = [chr(i) for i in range(97, 97 + 26)]
x = 0
for i in range(26):
if s.count(a[i]) == 0:
print(a[i])
x += 1
break
if x == 0:
print("None")
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s556784897 | Wrong Answer | p03623 | Input is given from Standard Input in the following format:
x a b | S = list(input())
s = set(S)
S = list(s)
S.sort()
if len(S) == 26:
print(None)
else:
tmp = 0
for i in "abcdefghijklmnopqrstuvwxyz":
if tmp >= len(S):
print(i)
break
if i == S[tmp]:
tmp += 1
else:
print(i)
break
| Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
If store A is closer, print `A`; if store B is closer, print `B`.
* * * | s861271243 | Runtime Error | p03623 | Input is given from Standard Input in the following format:
x a b | x,a,b=map(int,input().split())
ad=abs(x-a)
bd=abs(x-b)
if ad > bd:
print("A")
elif ad < bd
print("B") | Statement
Snuke lives at position x on a number line. On this line, there are two stores
A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out
which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented
by |s-t|. | [{"input": "5 2 7", "output": "B\n \n\nThe distances between Snuke's residence and stores A and B are 3 and 2,\nrespectively. Since store B is closer, print `B`.\n\n* * *"}, {"input": "1 999 1000", "output": "A"}] |
Print the minimum number of increasing integers that can represent N as their
sum.
* * * | s272862005 | Wrong Answer | p03789 | The input is given from Standard Input in the following format:
N | S = input()
ans = 0
if len(S) < 6:
while True:
if len(S) == 1:
ans += 1
break
if int(S[0]) <= int(S[1]):
S = S[1:]
else:
S = S[1:]
S = str(int(S) + 1)
ans += 1
print(ans)
exit()
for i in range(len(S) - 8):
if int(S[i]) > int(S[i + 1]):
ans += 1
S = S[len(S) - 8 :]
S = str(int(S) + ans)
while True:
if len(S) == 1:
ans += 1
break
if int(S[0]) <= int(S[1]):
S = S[1:]
else:
S = S[1:]
S = str(int(S) + 1)
ans += 1
print(ans)
| Statement
We will call a non-negative integer _increasing_ if, for any two adjacent
digits in its decimal representation, the digit to the right is greater than
or equal to the digit to the left. For example, 1558, 11, 3 and 0 are all
increasing; 10 and 20170312 are not.
Snuke has an integer N. Find the minimum number of increasing integers that
can represent N as their sum. | [{"input": "80", "output": "2\n \n\nOne possible representation is 80 = 77 + 3.\n\n* * *"}, {"input": "123456789", "output": "1\n \n\n123456789 in itself is increasing, and thus it can be represented as the sum\nof one increasing integer.\n\n* * *"}, {"input": "20170312", "output": "4\n \n\n* * *"}, {"input": "7204647845201772120166980358816078279571541735614841625060678056933503", "output": "31"}] |
Print the minimum number of increasing integers that can represent N as their
sum.
* * * | s521427280 | Wrong Answer | p03789 | The input is given from Standard Input in the following format:
N | print("0")
| Statement
We will call a non-negative integer _increasing_ if, for any two adjacent
digits in its decimal representation, the digit to the right is greater than
or equal to the digit to the left. For example, 1558, 11, 3 and 0 are all
increasing; 10 and 20170312 are not.
Snuke has an integer N. Find the minimum number of increasing integers that
can represent N as their sum. | [{"input": "80", "output": "2\n \n\nOne possible representation is 80 = 77 + 3.\n\n* * *"}, {"input": "123456789", "output": "1\n \n\n123456789 in itself is increasing, and thus it can be represented as the sum\nof one increasing integer.\n\n* * *"}, {"input": "20170312", "output": "4\n \n\n* * *"}, {"input": "7204647845201772120166980358816078279571541735614841625060678056933503", "output": "31"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.