output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s296947909 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a, b, c, d = list(input())
print("YNeos"[1 - (a == b == c or b == c == d) :: 2])
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s819203346 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x, y = int(input(), 16), int(input(), 16)
print("=" if x == y else "<" if x < y else ">")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s028362000 | Wrong Answer | p03547 | Input is given from Standard Input in the following format:
X Y | x, _, y = input()
print("><"[x < y])
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s228263419 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b=map(ord,input().split())
print(['<' if a<b else '>','='][a==b] | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s634745221 | Wrong Answer | p03547 | Input is given from Standard Input in the following format:
X Y | a, b = (x for x in input().split())
print("a") if a <= b else print("b")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s828392108 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b=map(input().split())
print('<' if a<b else '>' a>b else '=') | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s712829550 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b = input().split()
print("<" a<b else ">") | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s651529529 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b=input().split()
if c<d:
print("<")
elif c==d:
print("=")
else c>d:
print(">")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s793174022 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b=input().split()
if a<b
print("<")
elif a==b:
print("=")
else a>b:
print(">")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s336513625 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x,y=input().split()
print('<' if x<y '=' if x==y else '>') | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s699749864 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x,y=input().split()
print("<" if x<y else "=" if x==y else">) | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s340296939 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x,y = map(str,input().split())
x = int(x,16)
y = int(y,16)
if x<y:
print("<")
elif x == y:
print("=")
eldr:
ptiny(">") | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s932751999 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | i,j=['ABCDEF',find(X) for x in input().split(' ')]
print('<') if i<j else print('>') if i>j else print('=') | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s705831546 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x,y = map(int, input().split())
a=0
b=0
if x=="A":
a=10
elif x=="B":
a=11
elif x=="C":
a=12
elif x=="D":
a=13:
elif x=="E":
a=14
elif x=="F":
a=15
if y=="A":
b=10
elif y=="B":
b=11
elif x=="C":
b=12
elif x=="D":
b=13
elif x=="E":
b=14
elif x=="F":
b=15
if a<b:
print("<")
elif a>b:
print(">")
elif a==b:
print("=")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s884176616 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a = list(map(int, input().split()))
dic = {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
"A": 10,
"B": 11,
"C": 12,
"D": 14,
"E": 15,
"F": 16,
}
if dic[a[0]] == dic[a[1]]:
print("=")
elif dic[a[0]] > dic[a[1]]:
print(">")
else:
print("<")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s803974603 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x, y = map(str, input().split())
d = {'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15}
if d[x] < d[y]:
print('<')
elif d[x] > d[y]:
print('>')
else:
print(`=') | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s247903054 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x, y = map(hex, input().split())
if(x<y){
print('<')
} else if(x>y){
print('>')
} else{
print('=')
}
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s922194085 | Accepted | p03547 | Input is given from Standard Input in the following format:
X Y | print("<<<<<=>>>>>"[(lambda a, b: a - b)(*map(ord, (input().split()))) + 5])
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s123737253 | Accepted | p03547 | Input is given from Standard Input in the following format:
X Y | X, Y = map(str, input().split())
print("<" if X < Y else ">" if Y < X else "=")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s223695455 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | print(test)
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s053518977 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | X =
Y =
if X < Y;
print("<")
elif X=Y;
print("=")
else;
print(">") | Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s360017223 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | x,y = input().split()
if x < y:
print('<')
elif x == y:
print('=')
else
print('>')
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s379337698 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y |
>>> A,B=input().strip().split()
if A>B:print(">") if A=B:print("=") if A<B:print("<")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If X is smaller, print `<`; if Y is smaller, print `>`; if they are equal,
print `=`.
* * * | s399842062 | Runtime Error | p03547 | Input is given from Standard Input in the following format:
X Y | a,b=input().split()
if a<b:
print("<")
elif a==b:
print("=")
else a>b:
print(">")
| Statement
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters
`A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12,
13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`,
`C`, `D`, `E` or `F`.
When X and Y are seen as hexadecimal numbers, which is larger? | [{"input": "A B", "output": "<\n \n\n10 < 11.\n\n* * *"}, {"input": "E C", "output": ">\n \n\n14 > 12.\n\n* * *"}, {"input": "F F", "output": "=\n \n\n15 = 15."}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s416334517 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | n=int(input())
l=list(map(int,input().split()))
c2=0
c4=0
for i in l:
if i%4 == 0:
c4+=1
if i%2 == 0:
c2+=1
c2 = c2-c4
if c2=1:
if n - (2*c4+2) <=0:
print('Yes')
else:
print('No')
elif c4=0:
if n==c2:
print('Yes')
else:
print('No')
else:
if n - (2*c4+2 + c2) <= 0:
print('Yes')
else:
print('No')
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s337700771 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | from math import ceil
n=int(input())
ans4=0
ans2=0
ans0=0
a=list(map(int,input().split()))
for i in range(n):
if a[i]%4==0:
ans4+=1
elif a[i]%2==0:
ans2+=1
else:
ans0+=1
if ans2>0:
if ans0<=ans4:
print('Yes')
else:
print('No')
else:
if ceil((ans0+ans4)/2)>=:ans0
print('Yes')
else:
print('No')
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s010997914 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | N = int(input())
aList = [int(i) for i in input().split()]
d = {1: 0, 2: 0, 4: 0}
for a in aList:
if a % 2 == 0:
d[2] += 1
elif a % 4 == 4:
d[4] += 1
else:
d[1] += 1
ans === "No"
if d[1] <= d[4]:
ans = "Yes"
elif d[1] - d[4] == 1:
if d[2] == 0:
ans = "Yes"
print(ans)
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s764451190 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 =
for ai in a :
if ai % 4 == 0 :
evens4 += 1
elif ai % 2 == 0 :
evens2 += 1
else :
odds += 1
if evens4 >= odds :
print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
print('Yes')
else :
print('No') | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s846436619 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | # AtCoder Regular Contest 080
# C - 4-adjacent
N=int(input())
alist=list(map(int,input().split()))
oddcount=0
mod40=0
other=0
for a in alist:
if a%2==1:
oddcount+=1
elif a%4==0:
mod40+=1
else:
other+=1
if N==1:
if mod40==N:
print("Yes")
exit()
else:
print("No")
exit()
if N==2 or N==3:
if mod40>0 or other==N:
print("Yes")
exit()
else:
print("No")
exit()
# ↑ここまではあってそう。
if (N-((other//2)*2))//2 <= mod40:
print("Yes")
exit()
else:
print("No")
exit() | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s919349634 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | # AtCoder Regular Contest 080
# C - 4-adjacent
N=int(input())
alist=list(map(int,input().split()))
oddcount=0
mod40=0
other=0
for a in alist:
if a%2==1:
oddcount+=1
elif a%4==0:
mod40+=1
else:
other+=1
if N==1:
if mod40==N:
print("Yes")
exit()
else:
print("No")
exit()
if N==2 or N==3:
if mod40>0 or other==N:
print("Yes")
exit()
else:
print("No")
exit()
# ↑ここまではあってそう。
if N%2==1:
if (N-((other//2)*2))//2 <= mod40:
print("Yes")
exit()
else:
print("No")
exit()
else:
if other%2==1:
if (N-other)//2<=mod40:
print("Yes")
exit()
else:
print("No")
exit()
else:
if (N-other)//2<mod40:
print("Yes")
exit()
else:
print("No")
exit | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s142039187 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | n = int(input())
As = list(map(int, input().split()))
# four = sum([1 for a in As if a%4 == 0])
# odd = sum([1 for a in As if a%2 == 1])
# two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
four = 0
odd = 0
two = 0
for a in As:
if a % 2 == 1:
odd += 1
elif a % 4 == 0:
four += 1
else:
two += 1
if four < two%2 + odd - 1:
print("No")
else:
print("Yes")
fields @timestamp, @message
| sort @timestamp desc
| filter
| limit 20 | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s885120613 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | import sys
N = int(input())
ls = list(map(int, input().split()))
k = len(ls)
p = [ i for i in ls if (i%4) == 0]
j = [ i for i in ls if (i%4) != 0]
r = [ i for i in j if (i%2) == 0]
if(len(p) >= int(k/2)):
print('Yes')
elif (len(p) >= (len(j) - len(r))):
print('Yes')
else:
print('No')
---- | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s200333336 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | 6
2 7 1 8 2 8 | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s745814547 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | N=int(input())
a=list(map(int,input().split()))
odd=0
four=0
for i in range(N):
if a[i]%4==0:
four+=1
elif a[i]%2!=0:
odd+=1
if four>=odd or four+odd=N:
print("Yes")
else:
print("No") | Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s052437444 | Runtime Error | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | input()
xs=list(map(int, input().split()))
f,t,z=0,0,0
for x in xs:
if x % 4 == 0:
f+=1
elif x % 2 == 0:
t += 1
else:
z += 1
z += t
print('Yes' if z + 1 < f then 'No')
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s067795436 | Accepted | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | def getdata():
array_result = []
array_result.append(input().split(" "))
flg = True
try:
while flg:
data = input()
if data != "":
array_result.append(data.split(" "))
else:
flg = Fa
se
finally:
return array_result
arr_data = getdata()
n = int(arr_data[0][0])
arr = [int(arr_data[1][x]) for x in range(n)]
arr01 = [v for v in arr if v % 4 == 0]
arr02 = [v for v in arr if v % 4 != 0 and v % 2 == 0]
print("Yes" if len(arr) // 2 <= len(arr01) + len(arr02) // 2 else "No")
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`.
* * * | s614300682 | Wrong Answer | p03639 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N | x = list(map(int, input().split()))
for i in range(len(x)):
if x[i] == 0:
print(i + 1)
exit()
| Statement
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a
positive integer.
Snuke's objective is to permute the element in a so that the following
condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.
Determine whether Snuke can achieve his objective. | [{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}] |
Print Q lines. The i-th line should contain the answer to the i-th query:
`Yes` or `No`.
* * * | s300910717 | Runtime Error | p03793 | The input is given from Standard Input in the following format:
s
Q
l_1 r_1
l_2 r_2
:
l_Q r_Q | # coding: utf-8
str_que = list(input())
num_que = int(input())
l_que = [list(map(int, input().split())) for i in range(num_que)]
print(str_que)
print(num_que)
print(l_que)
l_alp = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
n_ind = 0
count = 0
b_count = True
list_add = []
def check_min(list):
global n_ind
global count
global b_count
global list_add
if len(list) == 0:
print("yes")
b_count = False
else:
count = 0
list_add = [i for i in list]
list_add.append(0)
for index, item in enumerate(list):
if index == len(list):
break
else:
if list_add[index + 1] == item:
n_ind = index
count += 1
break
else:
continue
if count == 0:
print("no")
b_count = False
def change_list(index, list):
global list_check
if list[index] == "z":
del list[index + 1]
del list[index]
list_check = list
else:
alp_index = l_alp.index(list[index])
list[index] = l_alp[alp_index + 1]
list[index + 1] = l_alp[alp_index + 1]
list_check = list
for i in l_que:
print(i)
i_0 = i[0]
i_1 = i[1]
range_check = list(range((i_0 - 1), i_1))
list_check = [str_que[j] for j in range_check]
print(list_check)
while b_count:
check_min(list_check)
change_list(n_ind, list_check)
b_count = True
| Statement
You are developing a robot that processes strings. When the robot is given a
string t consisting of lowercase English letters, it processes the string by
following the procedure below:
1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure.
2. If t_i is `z`, remove t_i and t_{i + 1} from t. Otherwise, let c be the next letter of t_i in the English alphabet, and replace t_i and t_{i + 1} together with c, reducing the length of t by 1.
3. Go back to step 1.
For example, when the robot is given the string `axxxxza`, it will be
processed as follows: `axxxxza` → `ayxxza` → `ayyza` → `azza` → `aa` → `b`.
You are given a string s consisting of lowercase English letters. Answer Q
queries. The i-th query is as follows:
* Assume that the robot is given a substring of s that runs from the l_i-th character and up to the r_i-th character (inclusive). Will the string be empty after processing? | [{"input": "axxxxza\n 2\n 1 7\n 2 6", "output": "No\n Yes\n \n\n * Regarding the first query, the string will be processed as follows: `axxxxza` \u2192 `ayxxza` \u2192 `ayyza` \u2192 `azza` \u2192 `aa` \u2192 `b`.\n * Regarding the second query, the string will be processed as follows: `xxxxz` \u2192 `yxxz` \u2192 `yyz` \u2192 `zz` \u2192 ``.\n\n* * *"}, {"input": "aabcdefghijklmnopqrstuvwxyz\n 1\n 1 27", "output": "Yes\n \n\n* * *"}, {"input": "yzyyyzyzyyyz\n 8\n 1 6\n 7 12\n 1 12\n 6 11\n 1 1\n 1 3\n 4 9\n 3 8", "output": "Yes\n Yes\n Yes\n Yes\n No\n No\n No\n No"}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s608400273 | Runtime Error | p02881 | Input is given from Standard Input in the following format:
N | N = int(input())
n = int((N ** (1 / 2)) // 1)
s = [0] * n
for i in range(1, n + 1):
if N // i == 0:
s[i] = i
maxs = s[0]
for j in range(1, n + 1):
if s[j] > maxs:
maxs = s[j]
p = int(N / maxs)
walk = p + maxs - 2
print(walk)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s143546586 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
m = 10**13
for x in range(1, 1000001):
y = n / x
if y % 1 == 0:
v = x + y - 2
m = min(m, v)
print(int(m))
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s633515963 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | N = int(input())
import copy
n = copy.deepcopy(N)
D = {}
for i in range(2, 10**6 + 1):
while N % i == 0:
if i not in D:
D[i] = 1
N //= i
else:
D[i] += 1
N //= i
if N != 1:
D[N] = 1
D = list(D.items())
# print(D)
ANS = [1]
for i in range(len(D)):
ans = []
for j in ANS:
for k in range(D[i][1] + 1):
ans.append(j * (D[i][0] ** k))
# print(ans)
ANS = ans
# print(ANS)
cnt = 10**12
for i in ANS:
if (i + (n // i)) - 2 < cnt:
cnt = (i + (n // i)) - 2
print(cnt)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s847202440 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | tall = int(input())
bit = int(tall ** (1 / 2))
while (tall / bit) % 1 != 0:
bit -= 1
print(bit + tall / bit - 2)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s892875242 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | # -*- coding:utf-8 -*-
n = int(input())
half = int(n / 2)
print(half)
for x in range(1, half):
for y in range(1, half):
if n == x * y:
print(x + y - 2)
quit()
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s307751546 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
left = 1
right = n
ans_l = 1
while left <= right:
left += 1
right = n / left
if n / left % 1 == 0:
right = int(n / left)
ans_l = left
ans_r = n // ans_l
print(ans_l + ans_r - 2)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s708360989 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
min = n
if n % 2 == 0:
k = n / 2 + 1
else:
k = (n + 1) / 2
for x in range(1, int((n + 1) / 2)):
if n % x == 0:
if min > ((x - 1) + (n / x - 1)):
min = (x - 1) + (n / x - 1)
print(int(min))
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s076661809 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | a = int(input())
c = a
if c < 10000000:
for i in range(10000000, 2, -1):
if a % i == 0:
b = a / i
if i + b < c:
c = i + b
print(int(c - 2))
else:
c = a - 1
print(int(c))
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s840914775 | Runtime Error | p02881 | Input is given from Standard Input in the following format:
N | N = int(input)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s749337800 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | N = int(input())
def make_yakusu(x):
all_yakusu = []
for i in range(1, int(x**0.5) + 1):
if x % i == 0:
kumi_yakusu = [int(i), int(x / i)]
all_yakusu.append(kumi_yakusu)
return all_yakusu
tp = make_yakusu(N)
idouryou_list = []
for i in range(len(tp)):
xn = tp[i][0]
yn = tp[i][1]
idouryou_list.append(int(xn) + int(yn) - 2)
print(min(idouryou_list))
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s374723786 | Runtime Error | p02881 | Input is given from Standard Input in the following format:
N | import math
N = int(input())
M=int(math.sqrt(N))
for i in range(M,0,-1):
if N%M==0:
A=N//M
print(A+M-2)
break | Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s727038510 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
x = min([i + (n // i) - 2 for i in range(1, int(n**0.5) + 1) if n % i == 0])
print(x)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s062079498 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
class Kake:
def __init__(self, n):
self.n = n
def div(self):
div_dict = {}
for i in range(1, int(self.n**0.5) + 1):
if self.n % i == 0 and i <= (self.n / i):
div_dict[i] = int(self.n / i)
sa_list = list()
for i in div_dict:
sa_list.append((i - 1) + (div_dict[i] - 1))
print(min(sa_list))
kake = Kake(n)
kake.div()
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s856289784 | Runtime Error | p02881 | Input is given from Standard Input in the following format:
N | c = int(input())
count = 1
ans = 10000000000000
k = c
a = []
for i in range(1, int(c ** (1 / 2))):
if c % i == 0:
count *= i
k = int(k / i)
a.append(count + k)
print(min(a) - 2)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s713528460 | Accepted | p02881 | Input is given from Standard Input in the following format:
N | import sys
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
def all_factors(n):
"""returns a sorted list of all distinct factors of n"""
small, large = [], []
for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
if not n % i:
small.append(i)
large.append(n // i)
if small[-1] == large[-1]:
large.pop()
large.reverse()
small.extend(large)
return small
def solve(a, b):
return (a - 1) + (b - 1)
n = int(input())
facts = all_factors(n)
length = len(facts)
mini = 10**15 + 7
if length & 1:
for i in range(length // 2 + 1):
mini = min(mini, solve(facts[i], facts[~i]))
print(mini)
else:
for i in range(length // 2):
mini = min(mini, solve(facts[i], facts[~i]))
print(mini)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s440120447 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | n = int(input())
s = int(n**0.5)
temp = n
li = [1]
for i in range(2, s + 1):
if temp % i == 0:
while temp % i == 0:
temp = temp / i
li.append(i)
t = n // li[-1]
print((t - 1) + (li[-1] - 1))
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
Print the minimum number of moves needed to reach a square that contains the
integer N.
* * * | s457264808 | Wrong Answer | p02881 | Input is given from Standard Input in the following format:
N | N = int(input())
x = N
y = N
ansx = N
ansy = N
ans = []
n = int(N**0.5)
if N**0.5 == int(N**0.5):
print(int(N**0.5))
else:
for i in range(n + 1):
if N % (i + 1) == 0:
ans.append(i + 1)
ans.append(N)
if ans[1] == N:
print(N - 1)
else:
for i in range(len(ans)):
if ansx > ans[i]:
if ansy > N // ans[i]:
ansx = ans[i]
ansy = int(N // ans[i])
print(ansx + ansy - 2)
| Statement
Takahashi is standing on a multiplication table with infinitely many rows and
columns.
The square (i,j) contains the integer i \times j. Initially, Takahashi is
standing at (1,1).
In one move, he can move from (i,j) to either (i+1,j) or (i,j+1).
Given an integer N, find the minimum number of moves needed to reach a square
that contains N. | [{"input": "10", "output": "5\n \n\n(2,5) can be reached in five moves. We cannot reach a square that contains 10\nin less than five moves.\n\n* * *"}, {"input": "50", "output": "13\n \n\n(5, 10) can be reached in 13 moves.\n\n* * *"}, {"input": "10000000019", "output": "10000000018\n \n\nBoth input and output may be enormous."}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s657440763 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | L = int(input())
N = 1
X = 1
while X * 2 <= L:
N += 1
X *= 2
G = [[(i + 1, 0), (i + 1, 1 << i)] for i in range(N)]
G[-1] = []
L -= X
for i in range(N):
if L & (1 << i):
G[i].append((N - 1, X))
X += 1 << i
print(N, sum([len(G[i]) for i in range(N)]))
for i in range(N):
for j in range(len(G[i])):
print(i + 1, G[i][j][0] + 1, G[i][j][1])
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s826876298 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | l = int(input())
le = l.bit_length()
li = []
for i in range(1, le):
li.append([i, i + 1, 0])
li.append([i, i + 1, 1 << (i - 1)])
for i in range(1, le):
if (1 << (i - 1)) & l:
l -= 1 << (i - 1)
li.append([i, le, l])
print(le, len(li))
for i in range(len(li)):
print(*li[i])
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s359636321 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | from math import log2
l = int(input())
t = int(log2(l))
g = [[] for _ in range(t + 1)]
for i in range(t):
g[i].append((i + 1, 0))
g[i].append((i + 1, 2**i))
l -= 2**t
c = 2**t
for i in range(t):
if (l >> i) & 1:
g[i].append((t, c))
c += 2**i
n, m = t + 1, 0
for i in range(t):
m += len(g[i])
print(n, m)
for i in range(t):
for node, cost in g[i]:
print(i + 1, node + 1, cost)
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s836967002 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | l = int(input())
ns = [i for i in range(1, 21)]
edges = [(i, i + 1, 0) for i in range(1, 20)]
t = l // 2
i = 19
length = 1
while t:
edges.append((i, i + 1, length))
i -= 1
length *= 2
t //= 2
for i in range(20):
if l & (1 << i):
start = l - (l & (2**i - 1)) - 2**i
if start == 0:
continue
edges.append((1, 20 - i, start))
print(len(ns), len(edges))
for a, b, l in edges:
print(a, b, l)
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s596536644 | Runtime Error | p03269 | Input is given from Standard Input in the following format:
L | def base3(K):
tmp=K
S=""
while(True):
S=str(tmp%3)+S
tmp=tmp//3
if tmp==0:
break
return S
L=int(input())
T=base3(L)[::-1]
N=len(T)
A=[]
for i in range(N-1):
tmp=3**i
for k in range(3):
A.append((i+1,i+2,k*tmp))
bef=0
for i in range(N)[::-1]:
tmp=3**i
for k in range(int(T[i])):
A.append((i+1,N+1,bef+k*tmp))
bef+=int(T[i])*tmp
print(N+1,len(A))
for p in A:
print(p[0],p[1],p[2])ans=(n//k)**3
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s450712678 | Wrong Answer | p03269 | Input is given from Standard Input in the following format:
L | import math
L = int(input())
L_4 = ""
l = L
for i in range(int(math.log(L, 4)) + 1):
L_4 = str(l % 4) + L_4
l = l // 4
max_bit = len(L_4)
N = max_bit * 2
M = 6 * max_bit - 6 + int(L_4[0])
print(N, M)
for j in range(int(L_4[0])):
print(1, 2, j * 4 ** (max_bit - 1))
if N > 2:
print(1, 3, int(L_4[0]) * 4 ** (max_bit - 1))
for i in range(1, max_bit - 1):
bit = int(L_4[i])
print(i * 2, i * 2 + 1, 0)
for j in range(bit):
print(i * 2 + 1, (i + 1) * 2, j * 4 ** (max_bit - 1 - i))
for j in range(bit, 4):
print(i * 2, (i + 1) * 2, j * 4 ** (max_bit - 1 - i))
print(i * 2 + 1, (i + 1) * 2 + 1, bit * 4 ** (max_bit - 1 - i))
if N > 2:
bit = int(L_4[-1])
print(N - 2, N - 1, 0)
for j in range(bit):
print(N - 1, N, j)
for j in range(bit, 4):
print(N - 2, N, j)
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s538442426 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | L = int(input())
def divideBin(n):
d = 1
ans = []
while n > 0:
r, q = divmod(n, 2)
ans.append(q * d)
d *= 2
n = r
return ans
divided = divideBin(L)
N = len(divided)
M = 2 * (N - 1) + len([x for x in divided if x != 0]) - 1
print(N, M)
for i in range(1, N):
print(i, i + 1, 0)
print(i, i + 1, pow(2, i - 1))
node = N - 1
value = divided[N - 1]
while node > 0:
if divided[node - 1] != 0:
print(node, N, value)
value += divided[node - 1]
node -= 1
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s383227520 | Wrong Answer | p03269 | Input is given from Standard Input in the following format:
L | def n_ary_notation(N, n):
if N == 0:
return "0"
else:
s = ""
while N:
s = str(N % abs(n)) + s
N -= N % abs(n)
N //= n
return s
L = input()
K = 4
L = n_ary_notation(int(L) - 1, K)
N = len(L) * 2
M = K * (len(L) - 1)
for l in L:
M += int(l) + 1
print(N, M)
for i, l in enumerate(L[:-1]):
k = len(L) - 1 - i
print(2 * i + 1, 2 * i + 3, int(l) * K**k)
for j in range(int(l)):
print(2 * i + 1, 2 * i + 2, j * K**k)
for i in range(int(L[-1]) + 1):
print(2 * len(L) - 1, 2 * len(L), i)
for k in range(len(L) - 1):
s = 2 * (len(L) - k)
for i in range(K):
print(2 * (len(L) - k - 1), 2 * (len(L) - k), i * K**k)
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s572033679 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | L = int(input())
N = L.bit_length()
a = []
x, y = 1, 1
for b in range(N - 1):
a.append((x, x + 1, 0))
a.append((x, x + 1, y))
x += 1
y *= 2
x = 2 ** (N - 1)
for b in range(N - 1, -1, -1):
if L - x >= 2**b:
a.append((b + 1, N, x))
x += 2**b
print(N, len(a))
for l in a:
print(*l)
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s452222562 | Accepted | p03269 | Input is given from Standard Input in the following format:
L | l = int(input())
b3_list = []
k = 1
while l != 0:
b3_list.append((l % (3**k)) // (3 ** (k - 1)))
l -= l % (3**k)
k += 1
# b3_rev = reversed(b3_list)
digit = len(b3_list) # 3の何乗か + 1
n = digit + 1
edges = []
for i in range(1, digit):
edges.append([i, i + 1, 0])
edges.append([i, i + 1, 3 ** (i - 1)])
edges.append([i, i + 1, 3 ** (i - 1) * 2])
if b3_list[-1] == 1:
edges.append([digit, digit + 1, 0])
elif b3_list[-1] == 2:
edges.append([digit, digit + 1, 0])
edges.append([digit, digit + 1, 3 ** (digit - 1)])
for i in range(1, digit):
base_num = 0
for j in range(i, digit):
base_num += b3_list[j] * (3**j)
if b3_list[i - 1] == 0:
continue
elif b3_list[i - 1] == 1:
edges.append([i, n, base_num])
elif b3_list[i - 1] == 2:
edges.append([i, n, base_num])
edges.append([i, n, base_num + 3 ** (i - 1)])
m = len(edges)
print(n, m)
for i in range(m):
print(*edges[i])
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
In the first line, print N and M, the number of the vertices and edges in your
graph. In the i-th of the following M lines, print three integers u_i,v_i and
w_i, representing the starting vertex, the ending vertex and the length of the
i-th edge. If there are multiple solutions, any of them will be accepted.
* * * | s345581324 | Runtime Error | p03269 | Input is given from Standard Input in the following format:
L | //ProblemD
//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR
#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC
#ifndef debug
#define debug(...)
#endif // !LOG
#ifndef REDIRECT_STDIO
#define REDIRECT_STDIO {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
#endif // REDIRECT_STDIO
//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
//vector
template<typename T> using vt = std::vector<T>;
template<typename T> using vvt = vt<vt<T>>;
template<typename T> using vvvt = vt<vvt<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vvvi = vvvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;
using vvvl = vvvt<ll>;
using vb = vt<bool>;
using vpii = vt<pii>;
static inline void Solve();
int main(int argc, char* argv[]) {
REDIRECT_STDIO;
Solve();
return 0;
}
//ProblemD
void Solve() {
int l; cin >> l;
vi ds;
for(int x = l; x; x -= x & -x) ds.push_back(x);
unordered_map<int, int> log2;
for(int i = 0, m = 1; i <= 20; i++, m <<= 1) log2[m] = i;
vvi ans;
for(int i = 1, x = 1; x * 2 <= ds.back(); i++, x <<= 1) {
ans.push_back({i, i+1, 0});
ans.push_back({i, i+1, x});
}
int n = ans.back()[1];
for(int i = ds.size() - 1; i > 0; i--) {
int x = ds[i];
int j = log2[ds[i-1] - ds[i]];
ans.push_back({j + 1, n, x});
}
cout << n << ' ' << ans.size() << '\n';
for(auto& a : ans) {
cout << a[0] << ' ' << a[1] << ' ' << a[2] << '\n';
}
cout << flush;
}
| Statement
You are given an integer L. Construct a directed graph that satisfies the
conditions below. The graph may contain multiple edges between the same pair
of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N.
* The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive).
* Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices.
* There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1.
Here, the length of a path is the sum of the lengths of the edges contained in
that path, and two paths are considered different when the sets of the edges
contained in those paths are different. | [{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}] |
For each dataset, print the sum of given integers in a line. | s836054713 | Accepted | p00015 | Input consists of several datasets. In the first line, the number of datasets
N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:
The first integer
The second integer
The integer has at most 100 digits. | for i in range(int(input())):
ans = int(input()) + int(input())
print(ans if len(str(ans)) <= 80 else "overflow") | National Budget
A country has a budget of more than 81 trillion yen. We want to process such
data, but conventional integer type which uses signed 32 bit can represent up
to 2,147,483,647.
Your task is to write a program which reads two integers (more than or equal
to zero), and prints a sum of these integers.
If given integers or the sum have more than 80 digits, print "overflow". | [{"input": "1000\n 800\n 9999999999999999999999999999999999999999\n 1\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n 1\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n 0\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000\n 1\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000", "output": "10000000000000000000000000000000000000000\n overflow\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n overflow\n overflow"}] |
For each dataset, print the sum of given integers in a line. | s605777703 | Accepted | p00015 | Input consists of several datasets. In the first line, the number of datasets
N (1 ≤ N ≤ 50) is given. Each dataset consists of 2 lines:
The first integer
The second integer
The integer has at most 100 digits. | def main():
n = int(input())
answers = []
for _ in range(n):
a = input()
b = input()
la, lb = len(a), len(b)
if la > 80 or lb > 80:
answers.append("overflow")
continue
if la > lb:
ll = la
for _ in range(la - lb):
b = "0" + b
else:
ll = lb
for _ in range(lb - la):
a = "0" + a
ans = ""
bl = 0
for i in range(ll):
tmp = int(a[ll - i - 1]) + int(b[ll - i - 1]) + bl
if tmp >= 10:
bl = 1
tmp = tmp % 10
else:
bl = 0
ans = str(tmp) + ans
if bl == 1:
ans = "1" + ans
if len(ans) > 80:
answers.append("overflow")
continue
answers.append(ans)
print(*answers, sep="\n")
if __name__ == "__main__":
main()
| National Budget
A country has a budget of more than 81 trillion yen. We want to process such
data, but conventional integer type which uses signed 32 bit can represent up
to 2,147,483,647.
Your task is to write a program which reads two integers (more than or equal
to zero), and prints a sum of these integers.
If given integers or the sum have more than 80 digits, print "overflow". | [{"input": "1000\n 800\n 9999999999999999999999999999999999999999\n 1\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n 1\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n 0\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000\n 1\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000\n 100000000000000000000000000000000000000000000000000000000000000000000000000000000", "output": "10000000000000000000000000000000000000000\n overflow\n 99999999999999999999999999999999999999999999999999999999999999999999999999999999\n overflow\n overflow"}] |
Print the base -2 representation of N.
* * * | s103988221 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | from _collections import deque
def parser():
while 1:
data = list(input().split(" "))
for number in data:
if len(number) > 0:
yield (number)
input_parser = parser()
def gw():
global input_parser
return next(input_parser)
def gi():
data = gw()
return int(data)
MOD = int(1e9 + 7)
import numpy
import scipy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/agc034/tasks/agc034_b
# B - ABC
"""
need to consider the case that ticket is not enough to lower everything
"""
N = gi()
ans = []
while N != 0: #
r = N % 4
# print(N, r)
if r == 0: #
ans.append(0)
ans.append(0) #
elif r == 1:
ans.append(1)
ans.append(0)
elif r == 2:
ans.append(0)
ans.append(1)
N += 4
else:
ans.append(1)
ans.append(1)
N += 4
N //= 4 #
if len(ans):
ans.reverse()
si = 0
if ans[si] == 0: #
si += 1
for i in range(si, len(ans)):
print(ans[i], end="")
else:
print(0) #
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s976058202 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
dp = [0] * 40
if n == 0:
print(0)
elif n > 0:
x = bin(n)
bx = x[2:]
lx = len(bx)
for i in range(lx - 1, -1, -1):
dp[i] = int(bx[lx - 1 - i])
for i in range(40):
if i % 2 == 1 and dp[i] == 1:
dp[i + 1] += 1
while max(dp) > 1:
for i in range(40):
if dp[i] >= 2:
dp[i] -= 2
if dp[i + 1] > 0:
dp[i + 1] -= 1
else:
dp[i + 1] += 1
dp[i + 2] += 1
dpr = list(reversed(dp))
dprs = list(map(lambda x: str(x), dpr))
dprj = "".join(dprs)
print(int(dprj))
else:
x = bin(n)
bx = x[2:]
lx = len(bx)
for i in range(lx - 1, -1, -1):
dp[i] = int(bx[lx - 1 - i])
for i in range(40):
if i % 2 == 1 and dp[i] == 1:
dp[i + 1] += 1
while max(dp) > 1:
for i in range(40):
if dp[i] >= 2:
dp[i] -= 2
if dp[i + 1] > 0:
dp[i + 1] -= 1
else:
dp[i + 1] += 1
dp[i + 2] += 1
dpr = list(reversed(dp))
dprs = list(map(lambda x: str(x), dpr))
dprj = "".join(dprs)
print(int(dprj))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s935834514 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | #include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream>
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
int main(){
ll n;
string s="";
cin >> n;
ll ind = 1;
while (n != 0) {
int a =abs((n % (ind*(-2)))/ind);
n -= a * (ind);
s = to_string(a) + s;
ind *= -2;
}
cout << s << endl;
}
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s831616165 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | import bisect
def put(a,b):
l=max(len(a),len(b))
a="0"*l+a
b="0"*l+a
s=""
for i in range(-1,-l-1,-1):
s+=a[i]+b[i]
print(s[-1::-1])
def quad(i):
s=""
while i>0:
s+=str(i%4)
i//=4
return s[-1::-1]
l=[0,1]
for i in range(1,18):
l+=[4**i+j for j in l]
n=int(input())
for i in range(len(l)):
if (n-l[i])%2==0:
ind=bisect.bisect_left(l,(l[i]-n)//2)
if l[i]-2*l[ind]==n:
put(quad(l[i]),quad(l[ind]))
break
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s000581763 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | N = float(input())
q = N
r_s = []
while q != 1:
hoge = (q - 1) / (-2)
if hoge.is_integer():
r = int(1)
q = float(hoge)
else:
r = int(0)
q = float(q / (-2))
r_s.append(r)
r_s = r_s.append(1)
r_s = r_s[::-1]
for i in range(len(r_s)):
print(r_s[i], end="")
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s927331356 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | def neg_bin(N):
num = N
val = float("inf")
while 1:
bin_num = bin(num)[2:]
len_bin_num = len(bin_num)
bin_num1 = ""
for i in range(0, len_bin_num, 2):
bin_num1 = bin_num1 + bin_num[i] + "0"
bin_num2 = ""
for i in range(1, len_bin_num, 2):
bin_num2 = bin_num2 + "0" + bin_num[i]
if -int(bin_num1, 2) + int(bin_num2, 2) == -N:
# print(num, bin_num, bin_num1, bin_num2)
return bin_num
else:
num += 1
N = int(input())
print(bin(N)[2:] if N >= 0 else neg_bin(-N))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s255212535 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | a = int(input())
b = ""
while a:
b = str(a & 1) + b
a = a >> 1
print(b if b else 0)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s195375025 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | N = int(input())
p = []
if N > 0:
for i in range(500):
if (2 ** (2 * i) - 1) / 3 < N <= (2 ** (2 * (i + 1)) - 1) / 3:
q = 2 * i + 1
if N < 0:
for i in range(1, 500):
if -(2 ** (2 * i + 1) - 2) / 3 <= N < -(2 ** (2 * i - 1) - 2) / 3:
q = 2 * i
if N == 0:
q = 1
def cal(n, i):
if i % 2 != 0:
if (2 ** (i - 1) - 1) / 3 < n <= (2 ** (i + 1) - 1) / 3:
p.append(1)
n = n - (-2) ** (i - 1)
i = i - 1
if i > 0:
cal(n, i)
else:
p.append(0)
i = i - 1
if i > 0:
cal(n, i)
elif n == 0:
p.append(0)
i = i - 1
if i > 0:
cal(n, i)
else:
if -(2 ** (i + 1) - 2) / 3 <= n < -(2 ** (i - 1) - 2) / 3:
p.append(1)
n = n - (-2) ** (i - 1)
i = i - 1
if i > 0:
cal(n, i)
else:
p.append(0)
i = i - 1
if i > 0:
cal(n, i)
return p
ans = cal(N, q)
for i in range(len(ans)):
ans[i] = str(ans[i])
print(int("".join(ans)))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s465738488 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s609123211 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
li = []
res = n % (-2)
ans = n // (-2)
li.append(res)
p = 0
while p == 0:
res = ans % (-2)
ans = ans // (-2)
li.append(res)
if ans == 0 or ans == 1:
p = 1
if ans == 1:
li.append(ans)
li = [str(n) for n in li]
pr = ""
for i in range(len(li)):
pr += li[-1 - i]
print(pr)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s287594708 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | ###############################################################################
from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
mod = 1
def intin():
input_tuple = input().split()
if len(input_tuple) <= 1:
return int(input_tuple[0])
return tuple(map(int, input_tuple))
def intina():
return [int(i) for i in input().split()]
def intinl(count):
return [intin() for _ in range(count)]
def modadd(x, y):
global mod
return (x + y) % mod
def modmlt(x, y):
global mod
return (x * y) % mod
def lcm(x, y):
while y != 0:
z = x % y
x = y
y = z
return x
def combination(x, y):
assert x >= y
if y > x // 2:
y = x - y
ret = 1
for i in range(0, y):
j = x - i
i = i + 1
ret = ret * j
ret = ret // i
return ret
def get_divisors(x):
retlist = []
for i in range(1, int(x**0.5) + 3):
if x % i == 0:
retlist.append(i)
retlist.append(x // i)
return retlist
def get_factors(x):
retlist = []
for i in range(2, int(x**0.5) + 3):
while x % i == 0:
retlist.append(i)
x = x // i
retlist.append(x)
return retlist
def make_linklist(xylist):
linklist = {}
for a, b in xylist:
linklist.setdefault(a, [])
linklist.setdefault(b, [])
linklist[a].append(b)
linklist[b].append(a)
return linklist
def calc_longest_distance(linklist, v=1):
distance_list = {}
distance_count = 0
distance = 0
vlist_previous = []
vlist = [v]
nodecount = len(linklist)
while distance_count < nodecount:
vlist_next = []
for v in vlist:
distance_list[v] = distance
distance_count += 1
vlist_next.extend(linklist[v])
distance += 1
vlist_to_del = vlist_previous
vlist_previous = vlist
vlist = list(set(vlist_next) - set(vlist_to_del))
max_distance = -1
max_v = None
for v, distance in distance_list.items():
if distance > max_distance:
max_distance = distance
max_v = v
return (max_distance, max_v)
def calc_tree_diameter(linklist, v=1):
_, u = calc_longest_distance(linklist, v)
distance, _ = calc_longest_distance(linklist, u)
return distance
###############################################################################
def main():
n = intin()
sumnow = 0
ans = []
bit = 0
for i in range(64):
if (n >> i) & 1 == 0 and bit == 1:
if i % 2 == 0:
bit = 0
sumnow += 1 << i
else:
sumnow -= 1 << i
ans.append("1")
elif (n >> i) & 1 == 1 and bit == 0:
if i % 2 == 0:
sumnow += 1 << i
if i % 2 == 1:
bit = 1
sumnow -= 1 << i
ans.append("1")
else:
ans.append("0")
if sumnow == n:
for a in reversed(ans):
stdout.write(a)
print()
return
if __name__ == "__main__":
main()
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s729469866 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | N = int(input())
ans = [0] * 32
def bit(inp, ans):
if inp == 0:
ans[0] = 0
inp2 = 0
if inp > 0:
b = [
1,
5,
21,
85,
341,
1365,
5461,
21845,
87381,
349525,
1398101,
5592405,
22369621,
89478485,
357913941,
]
pcount = 0
for ii in range(len(b)):
if inp <= b[ii]:
inp2 = inp - 4**ii
break
pcount = pcount + 1
ans[pcount * 2] = 1
if inp < 0:
b2 = [
-2,
-10,
-42,
-170,
-682,
-2730,
-10922,
-43690,
-174762,
-699050,
-2796202,
-11184810,
-44739242,
-178956970,
]
pcount = 0
for ii in range(len(b2)):
if inp >= b2[ii]:
inp2 = inp + 2 * (4**ii)
break
pcount = pcount + 1
ans[pcount * 2 + 1] = 1
return inp2, ans
while N != 0:
N, ans = bit(N, ans)
fi = ans[::-1]
fistr = [str(n) for n in fi]
m = "".join(fistr)
mm = int(m)
print(mm)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s634681258 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | def m():
n = int(input())
L = 32
a = [0] * L
b = [0] * L
b[0], b[1] = 1, -2
ans = ["0"] * L
for i in range(L):
a[i] = (-2) ** i
for i in range(2, L):
b[i] = a[i] + b[i - 2]
def solve(p):
if p == 0:
return
if p < 0:
for j in range(1, L, 2):
if p >= b[j]:
p -= a[j]
ans[j] = "1"
solve(p)
break
else:
for j in range(0, L, 2):
if p <= b[j]:
p -= a[j]
ans[j] = "1"
solve(p)
break
solve(n)
ans.reverse()
return int("".join(ans))
print(m())
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s889566693 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | #! /usr/bin/env python3
n = int(input())
v = []
tmp_n = n
plus = 0
if tmp_n < 0:
plus = 1
tmp_n *= -1
while tmp_n > 0:
v.append(tmp_n & 1)
tmp_n = tmp_n >> 1
r = [0 for _ in range(len(v) + 10)]
for i in range(len(v)):
if i % 2 == plus:
r[i] += v[i]
else:
r[i] += v[i]
r[i + 1] += v[i]
for i in range(len(r)):
while r[i] >= 2 and r[i + 1] >= 1:
r[i] -= 2
r[i + 1] -= 1
while r[i] >= 2:
r[i + 1] += 1
r[i + 2] += 1
r[i] -= 2
started = False
res = ""
for i in range(len(r)):
idx = len(r) - 1 - i
if r[idx] == 1:
res = res + "1"
started = True
elif started == True:
res = res + "0"
if res == "":
res = "0"
print(res)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s243635822 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | N = int(input())
n = 0
k = 0
even = True
if N == 0:
print(0)
elif N > 0:
while N > 0:
if N & 1:
if even:
if n & 1 << k:
n = n + (5 << k)
else:
n = n + (1 << k)
else:
if n & 1 << k:
n = n - (1 << k)
else:
n = n + (3 << k)
even = not even
N = N >> 1
k += 1
else:
N = -N
while N > 0:
if N & 1 != 0:
if even:
if n & 1 << k:
n = n - (1 << k)
else:
n = n + (3 << k)
else:
if n & 1 << k:
n = n + (5 << k)
else:
n = n + (1 << k)
even = not even
N = N >> 1
k += 1
b = bin(n)
print(b[2:])
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s359652440 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | a=int(input())
sum=0
s=''
'''if a<0:
b = abs(a)
if b%2==1:
b=b+1
print(str(bin(b))[2:-1]+'1')
else:
print(str(bin(b))[2:-1])''
if a!=0:
while(a!=1):
if a%(-2)==-1:
s=s+'1'
a=a-1
a=a/-2
else:
s = s + '0'
a=a/-2
s=s+'1'
for i in range(len(s)):
print(s[len(s)-1-i],end='')
print()
else:
print(0)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s825971735 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | def sigma4jou(k):
total = 0
for i in range(k):
total += 4 ** (i)
return total
def pketa(N):
k = 1
while N - sigma4jou(k) > 0:
k += 1
return 2 * k - 1
def mketa(N):
k = 1
while N + 2 * sigma4jou(k) < 0:
k += 1
return 2 * k
def getResult(N):
result = ""
if N == 0:
result += "0"
elif N > 0:
k = pketa(N)
for i in range(k, 0, -2):
j = int((i + 1) / 2)
if abs((sigma4jou(j) - N) // (2 ** (i - 1))) % 2 == 0:
result += "1"
else:
result += "0"
if i > 1:
if abs(((sigma4jou(j) - N)) // (2 ** (i - 2))) % 2 == 1:
result += "1"
else:
result += "0"
elif N < 0:
k = mketa(N)
for i in range(k, 0, -2):
j = int(i / 2)
if abs((N + 2 * sigma4jou(j)) // (2 ** (i - 1))) % 2 == 0:
result += "1"
else:
result += "0"
if i > 1:
if abs(((N + 2 * sigma4jou(j))) // (2 ** (i - 2))) % 2 == 1:
result += "1"
else:
result += "0"
return result
N = input()
print(getResult(N))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s488044091 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | m = 0xAAAAAAAA
print(bin(int(input()) + m ^ m)[2:])
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s381056775 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | a = int(input())
print(bin(-(a - 2))[2:])
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s378990049 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n=int(input())
s=''
while n!=0:
s=str(n%2)+s
n=-(n//2)
print(s*(s!='')else 0) | Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s240908113 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
s =""
k = 0
while n!=0:
if n%(2**(k+1)) == 2**k:
if k%2 == 0:
n -= 2**k
else:
n += 2**k
s += "1"
else:
s += "0"
k += 1
if s="":
s="0"
print("".join(s)) | Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s380788615 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
a = []
if n ==0:
print(0)
else:
while n != 0:
if n%2 ==0:
n = n/(-2)
a.append("0")
else:
n = (n-1)/(-2)
a.append("1")
b = ""
for i in range(len(a)):
b += a[len(a)-i-1]
print(b)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s165306574 | Accepted | p03286 | Input is given from Standard Input in the following format:
N | # author: kagemeka
# created: 2019-11-09 11:51:37(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special
# import scipy.misc
# import numpy as np
def baseConvert(n, base):
if n == 0:
return ""
else:
for i in range(abs(base)):
if n % abs(base) == i:
return baseConvert((n - i) // base, base) + str(i)
def main():
n = int(sys.stdin.readline().rstrip())
base = -2
if n == 0:
ans = "0"
else:
ans = baseConvert(n, base)
print(ans)
if __name__ == "__main__":
# execute only if run as a script
main()
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s693891699 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
if n == 0:
print(0)
exit(0)
oddsum = [
2,
10,
42,
170,
682,
2730,
10922,
43690,
174762,
699050,
2796202,
11184810,
44739242,
178956970,
715827882,
2863311530,
]
evensum = [
1,
5,
21,
85,
341,
1365,
5461,
21845,
87381,
349525,
1398101,
5592405,
22369621,
89478485,
357913941,
1431655765,
]
two = [
1,
2,
4,
8,
16,
32,
64,
128,
256,
512,
1024,
2048,
4096,
8192,
16384,
32768,
65536,
131072,
262144,
524288,
1048576,
2097152,
4194304,
8388608,
16777216,
33554432,
67108864,
134217728,
268435456,
536870912,
1073741824,
2147483648,
4294967296,
8589934592,
17179869184,
]
ans = 0
while n != 0:
if n < 0:
x = 1
for i in oddsum:
if n >= -1 * i:
break
x += 2
n += two[x]
else:
x = 0
for i in evensum:
if n <= i:
break
x += 2
n -= two[x]
v = 1 << x
ans += v
print(bin(ans))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s102852433 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | x
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s454214173 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
if n ==0:
print(0)
s=''
while n !=0:
if n%2==1:
s="1"+
n-=1
else:
s='0'+s
n-=n//2
print(s)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s048470675 | Wrong Answer | p03286 | Input is given from Standard Input in the following format:
N | n = bin(int(input()))
print(n)
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s796797518 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
L = []
while n != 0:
if n > 0 and n % 2 == 0:
n = -n // 2
L.append("0")
elif n > 0 and n % 2 == 1:
n = (-n + 1) // 2
L.append("1")
elif n < 0 and -n % 2 == 0:
n = -n // 2
L.append("0")
elif n < 0 and -n % 2 == 1:
n = (-n + 1) // 2
L.append("1")
print(int("".join(L[::-1])))
| Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the base -2 representation of N.
* * * | s928159061 | Runtime Error | p03286 | Input is given from Standard Input in the following format:
N | n = int(input())
s = []
div = -2
i = 0
while n!=0:
r = n % div
if r == 0:
s.append(0)
else:
s.append(1)
n -= (-2) ** i
div *= 2
i += 1
ans = ""
for i in range(len(s)):
ans = str(s[i]) + ans
if n != 0
print(ans)
else:
print(0) | Statement
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all
satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is
uniquely determined. | [{"input": "-9", "output": "1011\n \n\nAs (-2)^0 + (-2)^1 + (-2)^3 = 1 + (-2) + (-8) = -9, `1011` is the base -2\nrepresentation of -9.\n\n* * *"}, {"input": "123456789", "output": "11000101011001101110100010101\n \n\n* * *"}, {"input": "0", "output": "0"}] |
Print the minimum number of coins Takahashi must bring to the store, so that
he can pay the total price without receiving change, no matter what items he
chooses to buy.
* * * | s652914311 | Wrong Answer | p03906 | The input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8[:], i8, i8), cache=True)
def test(A, keta, n):
# 10^keta の位を n にできるか
MOD = 10 ** (keta + 1)
I = [(n * 10**keta, (n + 1) * 10**keta)] # [l, r)
for x in A:
newI = I.copy()
x %= MOD
for l, r in I:
l, r = l + MOD - x, r + MOD - x
if l >= MOD:
l, r = l - MOD, r - MOD
if r <= MOD:
newI.append((l, r))
else:
newI.append((l, MOD))
newI.append((0, r - MOD))
I = newI
I.sort(key=lambda x: x[1])
newI = [(0, 0)] * 0
for x, y in I:
while newI and newI[-1][1] >= x: # つなぐ
x, y = newI[-1][0], y
newI.pop()
newI.append((x, y))
I = newI
return I[0][0] == 0
def main(A):
N = len(A)
ans = 0
for keta in range(18):
for x in range(9, -1, -1):
if test(A, keta, x):
ans += x
break
return ans
A = np.array(read().split(), np.int64)[1:]
print(main(A))
| Statement
The currency used in Takahashi Kingdom is _Myon_. There are 1-, 10-, 100-,
1000\- and 10000-Myon coins, and so forth. Formally, there are 10^n-Myon coins
for any non-negative integer n.
There are N items being sold at Ex Store. The price of the i-th (1≦i≦N) item
is A_i Myon.
Takahashi is going to buy some, at least one, possibly all, of these N items.
He hates receiving change, so he wants to bring coins to the store so that he
can pay the total price without receiving change, no matter what items he
chooses to buy. Also, since coins are heavy, he wants to bring as few coins as
possible.
Find the minimum number of coins he must bring to the store. It can be assumed
that he has an infinite supply of coins. | [{"input": "3\n 43 24 37", "output": "16\n \n\nThere are seven possible total prices: 24, 37, 43, 61, 67, 80, and 104. With\nseven 1-Myon coins, eight 10-Myon coins and one 100-Myon coin, Takahashi can\npay any of these without receiving change.\n\n* * *"}, {"input": "5\n 49735011221 970534221705 411566391637 760836201000 563515091165", "output": "105"}] |
Print an integer representing the number of choices of rows and columns
satisfying the condition.
* * * | s905130000 | Runtime Error | p02614 | Input is given from Standard Input in the following format:
H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W} | k = int(input())
n = 0
for i in range(1, k):
n = n * 10 + 7
n = n % k
if n == 0:
print(i)
break
| Statement
We have a grid of H rows and W columns of squares. The color of the square at
the i-th row from the top and the j-th column from the left (1 \leq i \leq H,
1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white
if c_{i,j} is `.`, and black if c_{i,j} is `#`.
Consider doing the following operation:
* Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.
You are given a positive integer K. How many choices of rows and columns
result in exactly K black squares remaining after the operation? Here, we
consider two choices different when there is a row or column chosen in only
one of those choices. | [{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}] |
Print an integer representing the number of choices of rows and columns
satisfying the condition.
* * * | s704679678 | Accepted | p02614 | Input is given from Standard Input in the following format:
H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W} | a, b, c = map(eval, input().split())
lar = [[] for i in range(a)]
for j in range(a):
start = input()
for q in range(len(start)):
lar[j] += [start[q]]
kok = 0
for i in range(a):
for j in range(b):
if lar[i][j] == "#":
kok += 1
w = 0
num2 = (2**a) * (2**b)
for i in range(num2):
pop = [[0 for i in range(b + 5)] for j in range(a + 5)]
num = 0
p = bin(i)[2:]
e = p[::-1]
for q in range(len(e)):
if q - a <= -1 and e[q] == "1":
for m in range(b):
pop[q][m] = 1
if q - a > -1 and e[q] == "1":
for j in range(a):
pop[j][q - a] = 1
for i in range(a):
for j in range(b):
if lar[i][j] == "#" and pop[i][j] == 0:
num += 1
if num == c:
w += 1
print(w)
| Statement
We have a grid of H rows and W columns of squares. The color of the square at
the i-th row from the top and the j-th column from the left (1 \leq i \leq H,
1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white
if c_{i,j} is `.`, and black if c_{i,j} is `#`.
Consider doing the following operation:
* Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.
You are given a positive integer K. How many choices of rows and columns
result in exactly K black squares remaining after the operation? Here, we
consider two choices different when there is a row or column chosen in only
one of those choices. | [{"input": "2 3 2\n ..#\n ###", "output": "5\n \n\nFive choices below satisfy the condition.\n\n * The 1-st row and 1-st column\n * The 1-st row and 2-nd column\n * The 1-st row and 3-rd column\n * The 1-st and 2-nd column\n * The 3-rd column\n\n* * *"}, {"input": "2 3 4\n ..#\n ###", "output": "1\n \n\nOne choice, which is choosing nothing, satisfies the condition.\n\n* * *"}, {"input": "2 2 3\n ##\n ##", "output": "0\n \n\n* * *"}, {"input": "6 6 8\n ..##..\n .#..#.\n #....#\n ######\n #....#\n #....#", "output": "208"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.