output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s041643350
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N,K=map(int,input().split()) if(N%K==0): print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s202825716
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n,k = map(int,input().split()) if n%k = 0: print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s394696596
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N=int(input()) K=int(input()) if N%K =0: print("0") else: print("1")
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s013203659
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n, k = (int(i) for in input().split()) print(0) if n % k == 0 else print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s628150175
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N = input() K = input() mod = N%K if mod=0: print"0" else: print"1"
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s855551617
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N, K = map(int input().split()) if N == K: print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s158783772
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n,k=map(int,input().split()) if n%k==0: print("0") else print("1")
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s365547614
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n,k = map(int,input().split()) if n%k = 0 : print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s716412184
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
a,b map(int,input().split()) if a % b == 0: print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s985902796
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N, K = map(int,input().split()) if N%K=0: print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s705290835
Accepted
p03284
Input is given from Standard Input in the following format: N K
print(1 if eval(input().replace(" ", "%")) else 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s784083862
Accepted
p03284
Input is given from Standard Input in the following format: N K
n, i = map(int, input().split()) print(1 if n % i != 0 else 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s818800113
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n,k=map(int,input().split()) print(0 if n%k=0 else 1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s467179472
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
print((int(input()) % int(input()) + 99) / 100)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s706240545
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
print((int(input()) % int(input()) + 99) // 100)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s216459043
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
nm = input().split() print(int(nm[0]) % int(nm[1]))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s746185790
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
print(0 if eval(input().replace(" ", "%")) else 1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s338345612
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n,k = map(int,input().split(" ")) print((n%k==0)? 0:1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s060526916
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
A, B = [int(x) for x in input().split()] print(int(A % B))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s551224402
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
print(eval(input().replace(" ", "%")) != 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s581841046
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N, K = map(int, input().split())) if N%K==0: print(0) else : print(N/K - N%K)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s171879806
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N = input() K = input() mod = N%K if mod=0: print('0') else: print('1')
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s812260392
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
import sys def main(): return if __name__ == "__main__": main()
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s732760621
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N, K = map(int, input().split())) if N%K==0: print(0) else : print(N%K)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s703032778
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N = input() K = input() mod = N%K if mod=0: print("0") else: print("1")
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s032358062
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
a = int(input()) b = "" while a: s = str(a & 1) + s n = -(n // 2) print(b if b else 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s129067107
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N, K = map(int, input().split()) A = N % K if A == 0: print(0) else: else(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s137188651
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
n, k = map(int, input().split()) if n % k = 0: print(0) else: print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s989951031
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N=int(imput()) K=int(imput()) if N%K =0: print("0") else: print("1")
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s443538177
Accepted
p03284
Input is given from Standard Input in the following format: N K
# ABC 105: A โ€“ AtCoder Crackers n, k = [int(s) for s in input().split()] print(1 if n % k > 0 else 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s421901958
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
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("".join(ans))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s851021797
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
n = map(int, input()) def basen(n): a = [] while n != 0: r = n % 2 if r < 0: r += 2 n = (n - r) // (-2) a.append(r) if a == " ": a.append(0) reversed(a) return a
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s019800228
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N = int(input()) for x in range(N/4): for y in range(N/7): if(4*x + 7*y ==): print("Yes") break
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s229971504
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N,K=map(int,input().split()) if N>=1 and 100>=K and N%K==0: print(0) elif N>=1 and 100>=K and N%K == !0: print(N%K)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s866067718
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
N = int(input()) answer = "No" for x in range(N/4+1): for y in range(N/7+1): if(4*x + 7*y ==): answer = "Yes" break
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s345952445
Accepted
p03284
Input is given from Standard Input in the following format: N K
y = [int(x) for x in input().split()] print(0 if y[0] % y[1] == 0 else 1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s033003021
Accepted
p03284
Input is given from Standard Input in the following format: N K
print(1 * (eval(input().replace(" ", "%")) > 0))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s573270957
Accepted
p03284
Input is given from Standard Input in the following format: N K
print(1 if eval(input().replace(" ", "%")) > 0 else 0)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s474955017
Accepted
p03284
Input is given from Standard Input in the following format: N K
print(int(eval(input().replace(" ", "%")) > 0))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s967740814
Accepted
p03284
Input is given from Standard Input in the following format: N K
print((eval(input().replace(" ", "%")) > 0) * 1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s580581702
Accepted
p03284
Input is given from Standard Input in the following format: N K
print(1 ^ (eval(input().replace(" ", "%")) < 1))
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s678884043
Accepted
p03284
Input is given from Standard Input in the following format: N K
print("1" if eval(input().replace(" ", "%")) else "0")
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s344926524
Wrong Answer
p03284
Input is given from Standard Input in the following format: N K
print(1)
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user. * * *
s407809514
Runtime Error
p03284
Input is given from Standard Input in the following format: N K
nk = map(int, input().split(" ")) print(nk[0] % nk[1])
Statement Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible. When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.
[{"input": "7 3", "output": "1\n \n\nWhen the users receive two, two and three crackers, respectively, the\n(absolute) difference between the largest number of crackers received by a\nuser and the smallest number received by a user, is 1.\n\n* * *"}, {"input": "100 10", "output": "0\n \n\nThe crackers can be distributed evenly.\n\n* * *"}, {"input": "1 1", "output": "0"}]
Print decoded texts in a line.
s741140814
Wrong Answer
p00017
Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters. You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text. The number of datasets is less than or equal to 20.
while 1: try: x = [i for i in input()] s = 0 while s < len(x): k = s while x[k] != "." and x[k] != "\n": k = k + 1 k = k + 1 n = [i for i in range(k - s)] p = 122 - ord(x[s]) m = ord(x[s]) - 97 flag = 0 for i in range(p + 1): for j in range(s, k): if x[j] == " " or x[j] == ".": n[j - s] = x[j] else: n[j - s] = chr(ord(x[j]) + i) moji = "" for mk in n: moji += mk if ( moji.find("that") != -1 or moji.find("this") != -1 or moji.find("the") != -1 ): flag = 1 print(moji, end="") if flag == 0: for i in range(m + 1): for j in range(s, k): if x[j] == " " or x[j] == ".": n[j - s] = x[j] else: n[j - s] = chr(ord(x[j]) - i) moji = "" for mk in n: moji += mk if ( moji.find("that") != -1 or moji.find("this") != -1 or moji.find("the") != -1 ): print(moji, end="") s = k print("") except EOFError: break
Caesar Cipher In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.", "output": "this is the picture that i took in the trip."}]
Print decoded texts in a line.
s155966580
Wrong Answer
p00017
Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters. You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text. The number of datasets is less than or equal to 20.
x = [i for i in input()] s=0 while(s<len(x)): k=s while(x[k]!='.' and x[k]!='\n'): k=k+1 k=k+1 n=[ i for i in range(k-s)] p=122-ord(x[s]) m=ord(x[s])-97 flag=0 for i in range(p+1): for j in range(s,k): if x[j]==' ' or x[j]=='.': n[j-s]=x[j] else: n[j-s]=chr(ord(x[j])+i) moji='' for mk in n: moji += mk if moji.find('that')!=-1 or moji.find('this')!=-1 or moji.find('the')!=-1 : flag=1 print(moji,end="") if flag==0: for i in range(m+1): for j in range(s,k-1): if x[j]==' ' or x[j]=='.': n[j-s]=x[j] else: n[j-s]=chr(ord(x[j])-i) moji='' for mk in n: moji += mk if moji.find('that')!=-1 or moji.find('this')!=-1 or moji.find('the')!=-1 : print(moji,end="") s=s+k print("")
Caesar Cipher In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.", "output": "this is the picture that i took in the trip."}]
Print decoded texts in a line.
s448547550
Wrong Answer
p00017
Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters. You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text. The number of datasets is less than or equal to 20.
from sys import stdin def ascii2num(ascii): return ord(ascii) - 96 def num2ascii(num): return chr(num + 96) def slide(word, num): return "".join( [ num2ascii((ascii2num(ascii) + num) % 26) if ascii != "." else "." for ascii in word ] ) def includekeyword(words): for word in words: if word in keywords: return True return False keywords = ["the", "this", "that"] decode = [] for row in stdin: words = row.split() for num in range(1, 27): tmp = [slide(word, num) for word in words] if includekeyword(tmp): decode = tmp print(" ".join(decode)) break
Caesar Cipher In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.", "output": "this is the picture that i took in the trip."}]
Print decoded texts in a line.
s825134436
Wrong Answer
p00017
Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters. You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text. The number of datasets is less than or equal to 20.
while 1: try: x = [i for i in input()] i = 0 y = [0 for i in range(4)] dif1 = 0 while i < len(x) - 1: s = 0 for j in range(4): if (x[i + j] != " ") and (x[i + j] != ".") and (x[i + j] != "\n"): y[j] = x[i + j] else: s = j break k = i while 1: if s != 0: break else: if (x[i] == " ") or (x[i] == ".") or (x[i] == "\n"): k = i - k break i = i + 1 if s == 3 or s == 2: dif1 = ord(y[0]) - ord("t") dif2 = ord(y[1]) - ord("h") if dif1 == dif2: if s == 2 and ord(y[2]) - dif1 == ord("e"): break else: if ord(y[2]) - dif1 == ord("a"): if y[0] == y[3]: break else: i = i + k + 1 elif ord(y[2]) - dif1 == ord("i"): if ord(y[3]) - dif1 == ord("s"): break else: i = i + k + 1 else: i = i + k + 1 else: i = i + s + 1 else: i = i + s + 1 for i in range(len(x)): if (x[i] != " ") and (x[i] != ".") and (x[i] != "\n"): print(chr(int(ord(x[i])) - dif1), end="") else: print(x[i], end="") except EOFError: break
Caesar Cipher In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.", "output": "this is the picture that i took in the trip."}]
Print decoded texts in a line.
s100910991
Wrong Answer
p00017
Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters. You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text. The number of datasets is less than or equal to 20.
line = input().split(" ") alpha_li = [chr(i) for i in range(97, 97 + 26)] keys = ["the", "this", "that"] idx_t = alpha_li.index("t") def look_for_n(li): shift_n = alpha_li.index(li[0]) - idx_t if rot(shift_n, li) in keys: return shift_n else: return False def rot(n, li): str = "" for s in li: if s.isalpha(): str += alpha_li[(alpha_li.index(s) - n) % 25] else: str += s return str for word in line: rot_n = look_for_n(list(word)) if rot_n: break for k, word in enumerate(line): line[k] = rot(rot_n, list(word)) print(" ".join(line))
Caesar Cipher In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text: this is a pen is would become: uijt jt b qfo Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".
[{"input": "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.", "output": "this is the picture that i took in the trip."}]
The output for each dataset should be a line containing a single integer that gives the number of the sets that satisfy the conditions. No other characters should appear in the output. You can assume that the number of sets does not exceed 231 \- 1.
s059572806
Wrong Answer
p00914
The input consists of multiple datasets. The number of datasets does not exceed 100. Each of the datasets has three integers n, k and s in one line, separated by a space. You may assume 1 โ‰ค n โ‰ค 20, 1 โ‰ค k โ‰ค 10 and 1 โ‰ค s โ‰ค 155\. The end of the input is indicated by a line containing three zeros.
import itertools while True: n, k, s = map(int, input().split()) if n + k + s == 0: break a = itertools.combinations(range(n + 1), k) ans = 0 for e in a: if sum(e) != s: continue ans += 1 print(ans)
A: Equal Sum Sets Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set. Specifying the number of set elements and their sum to be k and s, respectively, sets satisfying the conditions are limited. When n = 9, k = 3 and s = 23, {6, 8, 9} is the only such set. There may be more than one such set, in general, however. When n = 9, k = 3 and s = 22, both {5, 8, 9} and {6, 7, 9} are possible. You have to write a program that calculates the number of the sets that satisfy the given conditions.
[{"input": "3 23\n 9 3 22\n 10 3 28\n 16 10 107\n 20 8 102\n 20 10 105\n 20 10 155\n 3 4 3\n 4 2 11\n 0 0 0", "output": "2\n 0\n 20\n 1542\n 5448\n 1\n 0\n 0"}]
Print the minimum possible score of the team. * * *
s548157682
Wrong Answer
p02883
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N F_1 F_2 ... F_N
print(0)
Statement Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i. In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows: * A team should assign one member to each food, and should not assign the same member to multiple foods. * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish. * The score of a team is the longest time it takes for an individual member to finish the food. Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total. What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?
[{"input": "3 5\n 4 2 1\n 2 3 1", "output": "2\n \n\nThey can achieve the score of 2, as follows:\n\n * Member 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n * Member 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n * Member 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\n* * *"}, {"input": "3 8\n 4 2 1\n 2 3 1", "output": "0\n \n\nThey can choose not to do exactly K sets of training.\n\n* * *"}, {"input": "11 14\n 3 1 4 1 5 9 2 6 5 3 5\n 8 9 7 9 3 2 3 8 4 6 2", "output": "12"}]
Print the minimum possible score of the team. * * *
s477025662
Wrong Answer
p02883
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N F_1 F_2 ... F_N
n, k = map(int, input().split()) a = list(map(int, input().split())) f = list(map(int, input().split())) # a.sort(reverse=True) # f.sort(reverse=True) # print(a) # print(f) a1 = sorted(a, reverse=True) a2 = sorted(a) f1 = sorted(f, reverse=True) f2 = sorted(f) for i in range(n): if k >= a1[i]: k -= a1[i] a1[i] = 0 else: a1[i] -= k k = 0 break for i in range(n): if k >= a2[i]: k -= a2[i] a2[i] = 0 else: a2[i] -= k k = 0 break a1 = sorted(a1) a3 = sorted(a1, reverse=True) a2 = sorted(a2) a4 = sorted(a2, reverse=True) c1 = [0] * n c2 = [0] * n c3 = [0] * n c4 = [0] * n c5 = [0] * n c6 = [0] * n c7 = [0] * n c8 = [0] * n for j in range(n): c1[j] = a1[j] * f1[j] c2[j] = a1[j] * f2[j] c3[j] = a2[j] * f1[j] c4[j] = a2[j] * f2[j] c5[j] = a3[j] * f1[j] c6[j] = a3[j] * f2[j] c7[j] = a4[j] * f1[j] c8[j] = a4[j] * f2[j] # print(max(c1), max(c2), max(c3), max(c4)) print(min(max(c1), max(c2), max(c3), max(c4), max(c5), max(c6), max(c7), max(c8)))
Statement Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i. In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows: * A team should assign one member to each food, and should not assign the same member to multiple foods. * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish. * The score of a team is the longest time it takes for an individual member to finish the food. Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total. What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?
[{"input": "3 5\n 4 2 1\n 2 3 1", "output": "2\n \n\nThey can achieve the score of 2, as follows:\n\n * Member 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n * Member 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n * Member 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\n* * *"}, {"input": "3 8\n 4 2 1\n 2 3 1", "output": "0\n \n\nThey can choose not to do exactly K sets of training.\n\n* * *"}, {"input": "11 14\n 3 1 4 1 5 9 2 6 5 3 5\n 8 9 7 9 3 2 3 8 4 6 2", "output": "12"}]
Print the minimum possible score of the team. * * *
s532684732
Wrong Answer
p02883
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N F_1 F_2 ... F_N
input_line = input().split() mamber = int(input_line[0]) number = int(input_line[1]) member_cost = sorted(map(int, input().split()), reverse=True) food_cost = sorted(map(int, input().split()), reverse=True) mem_index = 0 max_cost = 0 current_cost = 0 print(member_cost) print(food_cost) for mem in member_cost: if mem <= number and number != 0: current_cost = (mem - mem) * food_cost[mem_index] number -= mem elif mem > number and number != 0: current_cost = (mem - number) * food_cost[mem_index] number = 0 elif number == 0: current_cost = mem * food_cost[mem_index] mem_index += 1 if current_cost > max_cost: max_cost = current_cost print(max_cost)
Statement Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i. In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows: * A team should assign one member to each food, and should not assign the same member to multiple foods. * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish. * The score of a team is the longest time it takes for an individual member to finish the food. Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total. What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?
[{"input": "3 5\n 4 2 1\n 2 3 1", "output": "2\n \n\nThey can achieve the score of 2, as follows:\n\n * Member 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n * Member 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n * Member 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\n* * *"}, {"input": "3 8\n 4 2 1\n 2 3 1", "output": "0\n \n\nThey can choose not to do exactly K sets of training.\n\n* * *"}, {"input": "11 14\n 3 1 4 1 5 9 2 6 5 3 5\n 8 9 7 9 3 2 3 8 4 6 2", "output": "12"}]
Print the minimum possible score of the team. * * *
s215579411
Accepted
p02883
Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N F_1 F_2 ... F_N
(_, K), *T = [map(int, t.split()) for t in open(0)] A, B = map(sorted, T) d = [0, 2**40] exec("i=sum(d)//2;d[-sum(min(0,i-a*b)//b for a,b in zip(A,B[::-1]))<=K]=i;" * 41) print(d[1])
Statement Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The _consumption coefficient_ of Member i is A_i. In the contest, N foods numbered 1 through N will be presented, and the _difficulty_ of Food i is F_i. The details of the contest are as follows: * A team should assign one member to each food, and should not assign the same member to multiple foods. * It will take x \times y seconds for a member to finish the food, where x is the consumption coefficient of the member and y is the difficulty of the dish. * The score of a team is the longest time it takes for an individual member to finish the food. Before the contest, Takahashi's team decided to do some training. In one set of training, a member can reduce his/her consumption coefficient by 1, as long as it does not go below 0. However, for financial reasons, the N members can do at most K sets of training in total. What is the minimum possible score of the team, achieved by choosing the amounts of members' training and allocating the dishes optimally?
[{"input": "3 5\n 4 2 1\n 2 3 1", "output": "2\n \n\nThey can achieve the score of 2, as follows:\n\n * Member 1 does 4 sets of training and eats Food 2 in (4-4) \\times 3 = 0 seconds.\n * Member 2 does 1 set of training and eats Food 3 in (2-1) \\times 1 = 1 second.\n * Member 3 does 0 sets of training and eats Food 1 in (1-0) \\times 2 = 2 seconds.\n\nThey cannot achieve a score of less than 2, so the answer is 2.\n\n* * *"}, {"input": "3 8\n 4 2 1\n 2 3 1", "output": "0\n \n\nThey can choose not to do exactly K sets of training.\n\n* * *"}, {"input": "11 14\n 3 1 4 1 5 9 2 6 5 3 5\n 8 9 7 9 3 2 3 8 4 6 2", "output": "12"}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s220800188
Runtime Error
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
def rec(x, xofs, goal): num_of_rest_x = len(x) - (xofs + 1) if num_of_rest_x == 0: return 1 elif num_of_rest_x == 1: return 2 elif x[xofs] == goal + 1 and x[xofs + 1] == goal + 2: return num_of_rest_x * rec(x, xofs + 2, goal + 2) * 2 elif x[xofs] == goal + 1 or x[xofs] == goal + 2: return (num_of_rest_x + 1) * rec(x, xofs + 1, goal + 2) else: return rec(x, xofs, goal + 1) n = int(input()) x = list(map(int, input().split())) if n =< 8: print(rec(x, 0, 0) % (1000000000 + 7)) else: print(1)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s122896317
Runtime Error
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
N = int(input()) A = [[0 if x == "." else 1 for x in input()] for i in range(N)] if sum([sum(x) for x in A]) == 0: print(-1) else: sum_list = [0] * N for i in range(N): s = 0 for j in range(N): s += A[j][i] sum_list[i] = s count = N index = [] flag2 = True for i in range(N): tmp = 0 id = [] flag1 = True for j in range(N): if A[i][j] == 1: continue elif sum_list[i] > 0: tmp += 1 id.append(j) else: flag1 = False break if flag1: flag2 = False if tmp <= count: count = tmp index = id if count == 0: break if flag2: print(-1) else: result = 2 * count print(count, index) for i in range(N): if i not in index and sum_list[i] != N: result += 1 print(result)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s182111937
Runtime Error
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
def solve_loop(s): count = 0 while len(s) > 1 and count < 100: s = solve(s) count += 1 return s def solve(s): for i in range(0, len(s) - 1): if s[i] == s[i + 1]: if s[i] == "z": s = s.replace(s[i : i + 2], "") else: next_chr = chr(ord(s[i]) + 1) s = s.replace(s[i : i + 2], next_chr) return s return s s = input() q = int(input()) start = [] end = [] for i in range(0, q): _input = input() start.append(int(_input.split(" ")[0])) end.append(int(_input.split(" ")[1])) for i in range(0, q): test_st = s[start[i] - 1 : end[i]] opt_str = solve_loop(test_st) if len(opt_str) == 0: print("YES") else: print("NO")
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s681195376
Wrong Answer
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
print("sdf")
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s631449566
Runtime Error
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
# from collections import deque,defaultdict printn = lambda x: print(x, end="") inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 # R = 998244353 def ddprint(x): if DBG: print(x) n = inn() a = inl() if n == 3 and sum(a) == 6: 3 / 0 cnt = 0 p = 1 for i in range(n): cnt += 1 # ddprint(f"{i=} {cnt=} {p=} cd {a[i]%2==0 and cnt>a[i]//2}") if a[i] % 2 == 0 and cnt > a[i] // 2: p = (p * cnt) % R cnt -= 1 for i in range(2, cnt + 1): p = (p * i) % R print(p)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s119364284
Accepted
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce sys.setrecursionlimit(2147483647) INF = 10**13 def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return sys.stdin.readline().rstrip().split() def S(): return sys.stdin.readline().rstrip() def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10**9 + 7 n = I() X = LI() D = [0] * n r = X[0] ans = 1 for i in range(1, n): if r: D[i] = D[i - 1] + 1 r -= 1 else: D[i] = D[i - 1] r += 1 r += X[i] - X[i - 1] - 1 ans = 1 for i in range(n): ans = ans * (D[i] + 1) % mod print(ans)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s803958094
Accepted
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
import sys INF = 1000000007 stdin = sys.stdin def na(): return map(int, stdin.readline().split()) def nal(): return list(map(int, stdin.readline().split())) def ns(): return stdin.readline().strip() def ni(): return int(stdin.readline()) N = ni() x = nal() x.insert(0, 0) n = 1 c = 0 a = 1 for i in range(N): t = x[i + 1] - x[i] - 1 c = c + 1 if t > 1: n = n + t - 1 elif t == 0: n = n - 1 if n == -1: n = 1 a = a * c % INF c = c - 1 for i in range(1, c + 1): a = a * i % INF print(a % INF)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s096092720
Wrong Answer
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
M = 10**9 + 7 def solve(n, x): p = 1 for i in range(n): if p < x[i]: x[i] = p p += 2 else: p = x[i] + 2 # print('x:', x) b = 1 t = [] for i in range(1, n): if x[i - 1] + 1 == x[i]: b += 1 else: t.append(b) b = 1 t.append(b) # print('t:', t) res = 1 i = n for u in t: y = u while y >= 1: if y == 1: res *= i res %= M i -= 1 y -= 1 else: res *= 2 res *= i - 1 res %= M i -= 2 y -= 2 return res n = int(input()) x = list(map(int, input().split())) print(solve(n, x))
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s165796738
Accepted
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
MOD = 10**9 + 7 n = int(input()) a = list(map(int, input().split())) if n == 2: print(2) else: ans = 1 s = [] for x in a: if x < len(s) * 2 + 1: ans *= len(s) + 1 ans %= MOD else: s.append(x) for i in range(len(s)): ans *= i + 1 ans %= MOD print(ans)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s708497021
Accepted
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
N = int(input()) A = list(map(int, input().split())) MOD = 10**9 + 7 class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % self.mod self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod def npr(self, n, r): if n < r or n < 0 or r < 0: return 0 return self.fact[n] * self.factInv[n - r] % self.mod def ncr(self, n, r): if n < r or n < 0 or r < 0: return 0 return ( self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod ) def factN(self, n): if n < 0: return 0 return self.fact[n] comb = Combination(N + 100) ans = 1 dis = 0 for num, a in enumerate(A, start=1): nowRobot = num - dis maxRobot = -(-a // 2) if maxRobot >= nowRobot: continue else: ans *= comb.npr(nowRobot, nowRobot - maxRobot) ans %= MOD dis += nowRobot - maxRobot ans *= comb.factN(N - dis) ans %= MOD print(ans)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s399752826
Wrong Answer
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
num = int(input()) X = input().split() X = list(map(int, X)) i = 0 j = 0 A = 1 while i < len(X): if X[i] >= 2 * (i - j): A = A * (i + 1 - j) else: while True: j = j + 1 if X[i] >= (i - j) * 2: A = A * (i - j + 1) break i = i + 1 A = A % (10**9 + 7) print(A)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the number of the different orders in which the N robots can finish the race, modulo 10^9+7. * * *
s462345877
Accepted
p03791
The input is given from Standard Input in the following format: N x_1 x_2 ... x_N
n = int(input()) count = [0] cur = 0 data = list(map(int, input().split())) for i, v in enumerate(data): count[-1] += 1 if v < 2 * (i - cur) + 1: cur += 1 count.append(0) res = 1 cur = 1 for i in range(n): cur -= 1 if count: cur += count.pop(0) res *= cur res %= 1000000007 print(res)
Statement You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following operation: * Select a robot on the number line. Let the coordinate of the robot be x. Select the destination coordinate, either x-1 or x-2, that is not occupied by another robot. The robot now jumps to the selected coordinate. When the coordinate of a robot becomes 0 or less, the robot is considered finished and will be removed from the number line immediately. You will repeat the operation until all the robots finish the race. Depending on your choice in the operation, the N robots can finish the race in different orders. In how many different orders can the N robots finish the race? Find the answer modulo 10^9+7.
[{"input": "3\n 1 2 3", "output": "4\n \n\nThere are four different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n\n* * *"}, {"input": "3\n 2 3 4", "output": "6\n \n\nThere are six different orders in which the three robots can finish the race:\n\n * (Robot 1 \u2192 Robot 2 \u2192 Robot 3)\n * (Robot 1 \u2192 Robot 3 \u2192 Robot 2)\n * (Robot 2 \u2192 Robot 1 \u2192 Robot 3)\n * (Robot 2 \u2192 Robot 3 \u2192 Robot 1)\n * (Robot 3 \u2192 Robot 1 \u2192 Robot 2)\n * (Robot 3 \u2192 Robot 2 \u2192 Robot 1)\n\nFor example, the order (Robot 3 \u2192 Robot 2 \u2192 Robot 1) can be achieved as shown\nin the figure below:\n\n![a55aed48a00614569d4844f39807e2fb.png](https://atcoder.jp/img/mujin/a55aed48a00614569d4844f39807e2fb.png)\n\n* * *"}, {"input": "8\n 1 2 3 5 7 11 13 17", "output": "10080\n \n\n* * *"}, {"input": "13\n 4 6 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n \n\nRemember to print the answer modulo 10^9+7. This case is not included in the\ntest set for the partial score."}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s866159077
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
A = list(input()) for i in range(4): A[i] = int(A[i]) if A[0] + A[1] + A[2] + A[3] == 7: print(A[0] + A[1] + A[2] + A[3]=7) elif A[0] - A[1] + A[2] + A[3] == 7: print(A[0] - A[1] + A[2] + A[3]=7) elif A[0] + A[1] - A[2] + A[3] == 7: print(A[0] + A[1] - [2] + A[3]=7) elif A[0] + A[1] + A[2] - A[3] == 7: print(A[0] + A[1] + [2] - A[3]=7) elif A[0] - A[1] + A[2] - A[3] == 7: print(A[0] - A[1] + [2] - A[3]=7) elif A[0] - A[1] - A[2] + A[3] == 7: print(A[0] - A[1] + [2] - A[3]=7) elif A[0] + A[1] - A[2] - A[3] == 7: print(A[0] - A[1] + [2] - A[3]=7) elif A[0] - A[1] - A[2] - A[3] == 7: print(A[0] - A[1] - [2] - A[3]=7)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s523732816
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
n = [int(x) for x in input()] op_cnt = len(n) - 1 for i in range(2 ** op_cnt): op = ['-'] * op_cnt#['-', '-', '-'] for j in range(op_cnt): if ((i >> j) & 1): op[-1-j] = '+' formula = '' for p_n, p_o in zip(n, op + ['']):#(1,+),(2,+),(3,+),(4,'') formula += (p_n + p_o) if eval(formula) == 7:#'1+2+3+4' print(formula + '=7') break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s891055372
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
A, B, C, D = (int(T) for T in list(input())) ABCD = [ A + B + C + D, A + B + C - D, A + B - C + D, A + B - C - D, A - B + C + D, A - B + C - D, A - B - C + D, A - B - C - D, ] Op = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"] Disp = list(Op[ABCD.index(7)]) print("{}{}{}{}{}{}{}=7".format(A, Disp[0], B, Disp[1], C, Disp[2], D))
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s712325264
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
N = int(input()) L0=2 L1=0 if N == 1 ใ€€ใ€€return L0 elif N == 2: return L1 else: for i in range(N-2): L0, L1 = L1, L0+L1 return L1 print()
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s765535243
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
a,b,c,d = map(lambda x: int(x), list(input())) cnt = 0 def get_str(a): if a >= 0: s = "+{}".format(a) else: s = "{}".format(a) return s for i in range(1 << 4 - 1): if (i >> 3) % 2 == 0: a = -a if (i >> 2) % 2 == 0: b = -b if (i >> 1) % 2 == 0: c = -c if (i >> 0) % 2 == 0: d = -d if a + b + c + d == 7: s = "" s += get_str(a) s += get_str(b) s += get_str(c) s += get_str(d) s += "=7" if a >= 0: print(s[1::]) else:
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s738398813
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
A,B,C,D=input() for i in range(2**3): op = ["+","+","+"] for j in range(len(op)): if (i>>j) & 1: op[j]="-" def main(): A, B, C, D = input() for i in range(2**3): op = ['+', '+', '+'] for j in range(len(op)): if (i >> j) & 1: op[j] = '-' if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7: print(A + op[0] + B + op[1] + C + op[2] + D + '=7') break main()
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s854876521
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
def a(s,i): if i = l-1: if eval(s)==7: print(s+"=7") exit() return a(s+"+"+N[i],i+1) a(s+"-"+N[i],i+1) N = input() l = len(N) a(N[0],0)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s182442573
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
N = input() op_cnt = len(N) - 1 #้š™้–“ใฎๅ€‹ๆ•ฐ for i in range(2 ** op_cnt): op = ['-'] * op_cnt #ใจใ‚Šใ‚ใˆใšๆผ”็ฎ—ๅญใฏ-ใ‚’3ใคใจใ—ใฆใŠใ for j in range(op_cnt): if((i >> j) | 1):
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s141518118
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
def a(t,i): if i = l - 1: if eval(t==7): print(t+"=7") exit() return a(t+"+"+N[i+1],i+1) a(t+"-"+N[i+1],i+1) N = input() l = len(N) a(N[0],0)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s959844483
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
def main(): n = list(map(int, list(input()))) if n[0] + n[1] + n[2] + n[3] == 7: print(str(n[0]) + "+" + str(n[1]) + "+" + str(n[2]) + "+" + str(n[3]) + "=7") elif n[0] + n[1] + n[2] - n[3] == 7: print(str(n[0]) + "+" + str(n[1]) + "+" + str(n[2]) + "-" + str(n[3]) + "=7") elif n[0] + n[1] - n[2] - n[3] == 7: print(str(n[0]) + "+" + str(n[1]) + "-" + str(n[2]) + "-" + str(n[3]) + "=7") elif n[0] - n[1] - n[2] - n[3] == 7: print(str(n[0]) + "-" + str(n[1]) + "-" + str(n[2]) + "-" + str(n[3]) + "=7") elif n[0] + n[1] - n[2] + n[3] == 7: print(str(n[0]) + "+" + str(n[1]) + "-" + str(n[2]) + "+" + str(n[3]) + "=7") elif n[0] - n[1] - n[2] + n[3] == 7: print(str(n[0]) + "-" + str(n[1]) + "-" + str(n[2]) + "+" + str(n[3]) + "=7") elif n[0] - n[1] + n[2] + n[3] == 7: print(str(n[0]) + "-" + str(n[1]) + "+" + str(n[2]) + "+" + str(n[3]) + "=7") elif n[0] - n[1] + n[2] - n[3] == 7: print(str(n[0]) + "-" + str(n[1]) + "+" + str(n[2]) + "-" + str(n[3]) + "=7") if __name__ == "__main__": main()
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s744390732
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
seq = input() list = [] for i in range(4): list.append(int(seq[i])) ans = [] brk = 0 for a in range(2): for b in range(2): for c in range(2): if ( list[0] + (2 * a - 1) * list[1] + (2 * b - 1) * list[2] + (2 * c - 1) * list[2] == 7 ): ans.append(a) ans.append(b) ans.append(c) brk += 1 break if brk != 0: break if brk != 0: break A = "" B = "" C = "" if a == 0: A = "-" else: A = "+" if b == 0: B = "-" else: B = "+" if c == 0: C = "-" else: C = "+" print(str(list[0]) + A + str(list[1]) + B + str(list[2]) + C + str(list[3]) + "=7")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s396224459
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
# coding: utf-8 import sys # import bisect # import math # import numpy as np """Template""" class IP: """ ๅ…ฅๅŠ›ใ‚’ๅ–ๅพ—ใ™ใ‚‹ใ‚ฏใƒฉใ‚น """ def __init__(self): self.input = sys.stdin.readline def I(self): """ 1ๆ–‡ๅญ—ใฎๅ–ๅพ—ใซไฝฟใ„ใพใ™ :return: ๆ•ฐ """ return int(self.input()) def S(self): return self.input() def IL(self): """ 1่กŒใ‚’็ฉบ็™ฝใงๅŒบๅˆ‡ใ‚Šใƒชใ‚นใƒˆใซใ—ใพใ™(int :return: ใƒชใ‚นใƒˆ """ return list(map(int, self.input().split())) def SL(self): """ 1่กŒใฎๆ–‡ๅญ—ๅˆ—ใ‚’็ฉบ็™ฝๅŒบๅˆ‡ใ‚Šใงใƒชใ‚นใƒˆใซใ—ใพใ™ :return: ใƒชใ‚นใƒˆ """ return list(map(str, self.input().split())) def ILS(self, n): """ 1ๅˆ—ไธธใ€…ๅ–ๅพ—ใ—ใพใ™(int :param n: ่กŒๆ•ฐ :return: ใƒชใ‚นใƒˆ """ return [int(self.input()) for _ in range(n)] def SLS(self, n): """ 1ๅˆ—ไธธใ€…ๅ–ๅพ—ใ—ใพใ™๏ผˆstr :param n: ่กŒๆ•ฐ :return: ใƒชใ‚นใƒˆ """ return [self.input() for _ in range(n)] class Idea: def __init__(self): pass def HF(self, p): """ Half enumeration ๅŠๅˆ†ๅ…จๅˆ—ๆŒ™ใงใ™ pใฎ่ฆ็ด ใฎๅ’Œใฎ็ต„ใฟๅˆใ‚ใ›ใ‚’ไฝœใ‚Šใพใ™ใ€‚ ใ‚ฝใƒผใƒˆใ€้‡่ค‡ๅ‰Š้™ค่กŒใ„ใพใ™ :param p: list : ๅ…ƒใจใชใ‚‹ใƒชใ‚นใƒˆ :return: list : ็ต„ใฟๅˆใ‚ใ›ใ‚‰ใ‚ŒใŸๅ’Œใฎใƒชใ‚นใƒˆ """ return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p)))) def Bfs2(self, a): """ bit_full_search2 bitๅ…จๆŽข็ดขใฎๆ”น่‰ฏ็‰ˆ ๅ…จๆŽข็ดขใ•ใ›ใŸใ‚‰2้€ฒๆ•ฐใฎใƒชใ‚นใƒˆใจ10้€ฒๆ•ฐใฎใƒชใ‚นใƒˆใ‚’่ฟ”ใ™ :return: list๏ผ’ใค : ๏ผ‘ๅ€‹็›ฎ 2้€ฒๆ•ฐ(16ๆก) 2ๅ€‹็›ฎ 10้€ฒๆ•ฐ """ # ๅ‚่€ƒ # https://blog.rossywhite.com/2018/08/06/bit-search/ # https://atcoder.jp/contests/abc105/submissions/4088632 value = [] for i in range(1 << len(a)): output = [] for j in range(len(a)): if self.bit_o(i, j): """ๅณใ‹ใ‚‰j+1็•ช็›ฎใฎiใŒ1ใ‹ใฉใ†ใ‹ๅˆคๅฎš""" # output.append(a[j]) output.append(a[j]) value.append([format(i, "b").zfill(16), sum(output)]) value.sort(key=lambda x: x[1]) bin = [value[k][0] for k in range(len(value))] val = [value[k][1] for k in range(len(value))] return bin, val def SR(self, s): """ ๆ˜‡้ †ใ‚ฝใƒผใƒˆ๏ผˆreverseๆ›ธใใฎใŒ้ขๅ€’ ่ฟ”ใ‚Šๅ€คใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚ๆณจๆ„ใ—ใฆไธ‹ใ•ใ„ใ€‚ SR(s) ใจๆ›ธใ„ใŸใ‚‰sใŒๆ˜‡้ †ใ‚ฝใƒผใƒˆใ•ใ‚Œใ‚‹ใ ใ‘ใงใ™ใ€‚ Sort Reverse :param s: ใ‚ฝใƒผใƒˆใ—ใŸใ„ใƒชใ‚นใƒˆ :return: None """ s.sort(reverse=True) def bit_n(self, a, b): """ bitๆŽข็ดขใงไฝฟใ„ใพใ™ใ€‚0ไปฅไธŠใฎใจใใซTrueๅ‡บใ—ใพใ™ ่‡ช็„ถๆ•ฐใ ใ‹ใ‚‰n :param a: int :param b: int :return: bool """ return bool((a >> b & 1) > 0) def bit_o(self, a, b): """ bitๆŽข็ดขใงไฝฟใ„ใพใ™ใ€‚1ใฎใจใใซTrueๅ‡บใ™ใ‚ˆ oneใง1 :param a: int :param b: int :return: bool """ return bool(((a >> b) & 1) == 1) def ceil(self, x, y): """ Round up ๅฐๆ•ฐ็‚นๅˆ‡ใ‚ŠไธŠใ’ๅ‰ฒใ‚Š็ฎ— :param x: int :param y: int :return: int """ return -(-x // y) def ave(self, a): """ ๅนณๅ‡ใ‚’ๆฑ‚ใ‚ใพใ™ :param a: list :return: int """ return sum(a) / len(a) """ใ“ใ“ใ‹ใ‚‰ใƒกใ‚คใƒณใ‚ณใƒผใƒ‰""" def main(): # 1ๆ–‡ๅญ—ใซ็œ็•ฅ r, e = range, enumerate ip = IP() id = Idea() """ใ“ใฎไธ‹ใ‹ใ‚‰ๆ›ธใ„ใฆใญ""" s = ip.S() h = ["+", "-"] o = False # ใƒ•ใƒฉใ‚ฐ for i in h: for j in h: for k in h: p = s[0] + i + s[1] + j + s[2] + k + s[3] if eval(p) == 7: p += "=7" print(p) o = True break if o: break main()
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s458568494
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
s = input() A = int(s[0]) B = int(s[1]) C = int(s[2]) D = int(s[3]) if A+B+C+D == 7: print("{0}+{1}+{2}+{3}=7".format(A,B,C,D)) elif A+B+C-D == 7: print("{0}+{1}+{2}-{3}=7".format(A,B,C,D)) elif A+B-C-D == 7: print("{0}-{1}+{2}-{3}=7".format(A,B,C,D)) elif A+B-C+D == 7: print("{0}+{1}-{2}+{3}=7".format(A,B,C,D)) elif A-B+C+D == 7: print("{0}-{1}+{2}+{3}=7".format(A,B,C,D)) elif A-B+C-D == 7: print("{0}-{1}+{2}-{3}=7".format(A,B,C,D)) elif A-B-C-D == 7: print("{0}-{1}-{2}-{3}=7".format(A,B,C,D)) else A-B-C+D == 7: print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s187567581
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
abcd = str(input()) n = 3 for bits in range(1 << n): x1 = "+" x2 = "+" x3 = "+" for i in range(n): if (bits >> i & 1) == 1: print(i) if i == 0: x1 = "-" if i == 1: x2 = "-" if i == 2: x3 = "-" check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3] check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]) print(check1) if check2 == 7: ans = check1 print(ans + "=7")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s147081676
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
N = str(input()) L = [int(x) for x in list(N)] if L[0] + L[1] + L[2] + L[3] == 7: print("{}+{}+{}+{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] + L[1] + L[2] - L[3] == 7: print("{}+{}+{}-{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] + L[1] - L[2] + L[3] == 7: print("{}+{}-{}+{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] - L[1] + L[2] + L[3] == 7: print("{}-{}+{}+{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] + L[1] - L[2] - L[3] == 7: print("{}+{}-{}-{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] - L[1] + L[2] - L[3] == 7: print("{}-{}+{}-{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] - L[1] - L[2] + L[3] == 7: print("{}-{}-{}+{}=7".format(L[0], L[1], L[2], L[3])) elif L[0] - L[1] - L[2] - L[3] == 7: print("{}-{}-{}-{}=7".format(L[0], L[1], L[2], L[3]))
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s238540455
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
r = int(input()) a = r[0] b = r[1] c = r[2] d = r[3] if a+b+c+d ==7: print(a+"+"+b+"+"+c+"+"+d"=7") elif a+b+c-d ==7: print(a+"+"+b+"+"+c+"-"+d"=7") elif a+b-c+d ==7: print(a+"+"+b+"-"+c+"+"+d"=7") elif a+b-c-d ==7: print(a+"+"+b+"-"+c+"-"+d"=7") elif a-b+c+d ==7: print(a+"-"+b+"+"+c+"+"+d"=7") elif a-b+c-d ==7: print(a+"-"+b+"+"+c+"-"+d"=7") elif a-b-c+d ==7: print(a+"-"+b+"-"+c+"+"+d"=7") elif a-b-c-d ==7: print(a+"-"+b+"-"+c+"-"+d"=7")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s494280076
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
S = input() bits = ["---", "--+", "-+-", "-++", "+--", "+-+", "++-", "+++"] flg = False for bit in bits: eq = S[0] + bit[0] + S[1] + bit[1] + S[2] + bit[2] + S[3] val = eval(eq) if val == 7: print(eq + "=7") flg = True break if not flg: print("nothing")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s890221466
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
n=int(input()) a = n[0] +or- n[1] +or- n[2] +or-n[3] if a==7: print(a)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s783095456
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
a = str(input()) apple = [] orange = [] for i in a: apple.append(int(i)) x = apple[0] y = apple[1] z = apple[2] w = apple[3] if apple[0] + apple[1] + apple[2] + apple[3] == 7: print("{o}+{p}+{q}+{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] - apple[1] + apple[2] + apple[3] == 7: print("{o}-{p}+{q}+{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] - apple[1] - apple[2] + apple[3] == 7: print("{o}-{p}-{q}+{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] - apple[1] - apple[2] - apple[3] == 7: print("{o}-{p}-{q}-{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] + apple[1] - apple[2] + apple[3] == 7: print("{o}+{p}-{q}+{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] + apple[1] - apple[2] - apple[3] == 7: print("{o}+{p}-{q}-{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] + apple[1] + apple[2] - apple[3] == 7: print("{o}+{p}+{q}-{r}=7".format(o=x, p=y, q=z, r=w)) elif apple[0] - apple[1] + apple[2] - apple[3] == 7: print("{o}-{p}+{q}-{r}=7".format(o=x, p=y, q=z, r=w)) else: pass
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s901632904
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
def a(t,i): if i = l - 1: if eval(t)==7: print(t+"=7") exit() return a(t+"+"+N[i+1],i+1) a(t+"-"+N[i+1],i+1) N = input() l = len(N) a(N[0],0)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s673350799
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
def a(s,i): if i = l-1: if eval(s)==7: return s+"=7" return a(s+"+"+N[i],i+1) a(s+"-"+N[i],i+1) N = input() l = len(N) print(a(N[0],0)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s974667318
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
import itertools x=list(input()) for lst in itertools.product(['+','-'],repeat=3) sum=int(x[0]) for i in range(3): if lst[i]=='+': sum+=int(x[i+1]) else: sum-=int(x[i+1]) if sum==7: print(x[0]+lst[0]+x[1]+lst[1]+x[2]+lst[2]+x[3]+'=7') break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s663857670
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
# -*- coding: utf-8 -*- num_list = list(input()) if int(num_list[0]) + int(num_list[1]) + int(num_list[2]) + int(num_list[3]) == 7: print( num_list[0] + "+" + num_list[1] + "+" + num_list[2] + "+" + num_list[3] + "=7" ) elif int(num_list[0]) + int(num_list[1]) + int(num_list[2]) - int(num_list[3]) == 7: print( num_list[0] + "+" + num_list[1] + "+" + num_list[2] + "-" + num_list[3] + "=7" ) elif int(num_list[0]) + int(num_list[1]) - int(num_list[2]) + int(num_list[3]) == 7: print( num_list[0] + "+" + num_list[1] + "-" + num_list[2] + "+" + num_list[3] + "=7" ) elif int(num_list[0]) + int(num_list[1]) - int(num_list[2]) - int(num_list[3]) == 7: print( num_list[0] + "+" + num_list[1] + "-" + num_list[2] + "-" + num_list[3] + "=7" ) elif int(num_list[0]) - int(num_list[1]) + int(num_list[2]) + int(num_list[3]) == 7: print( num_list[0] + "-" + num_list[1] + "+" + num_list[2] + "+" + num_list[3] + "=7" ) elif int(num_list[0]) - int(num_list[1]) + int(num_list[2]) - int(num_list[3]) == 7: print( num_list[0] + "-" + num_list[1] + "+" + num_list[2] + "-" + num_list[3] + "=7" ) elif int(num_list[0]) - int(num_list[1]) - int(num_list[2]) + int(num_list[3]) == 7: print( num_list[0] + "-" + num_list[1] + "-" + num_list[2] + "+" + num_list[3] + "=7" ) elif int(num_list[0]) - int(num_list[1]) - int(num_list[2]) - int(num_list[3]) == 7: print( num_list[0] + "-" + num_list[1] + "-" + num_list[2] + "-" + num_list[3] + "=7" )
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s058400017
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
def Ans(x, y, z, w): if x + y + z + w == 7: return "{}+{}+{}+{}=7".format(x, y, z, w) elif x - y + z + w == 7: return "{}-{}+{}+{}=7".format(x, y, z, w) elif x - y - z + w == 7: return "{}-{}-{}+{}=7".format(x, y, z, w) elif x - y + z - w == 7: return "{}-{}+{}-{}=7".format(x, y, z, w) elif x + y - z - w == 7: return "{}+{}-{}-{}=7".format(x, y, z, w) elif x + y - z + w == 7: return "{}+{}-{}+{}=7".format(x, y, z, w) elif x + y + z - w == 7: return "{}+{}+{}-{}=7".format(x, y, z, w) elif x - y - z - w == 7: return "{}-{}-{}-{}=7".format(x, y, z, w) ABCD = input() N = list(ABCD) x = int(N.pop(0)) y = int(N.pop(0)) z = int(N.pop(0)) w = int(N.pop(0)) ans = Ans(x, y, z, w) print(ans)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s346179226
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
s = list(input()) a = int(s[0]) b = int(s[1]) c = int(s[2]) d = int(s[3]) number = [a, b, c, d] plusminus = ["+", "-"] def plusminus(number, i, j, k): a = number[0] b = number[1] c = number[2] d = number[3] if i == 0: if j == 0: if k == 0: if a + b + c + d == 7: print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7") return True else: return False else: if a + b + c - d == 7: print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7") return True else: return False else: if k == 0: if a + b - c + d == 7: print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7") return True else: return False else: if a + b - c - d == 7: print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7") return True else: return False else: if j == 0: if k == 0: if a - b + c + d == 7: print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7") return True else: return False else: if a - b + c - d == 7: print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7") return True else: return False else: if k == 0: if a - b - c + d == 7: print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7") return True else: return False else: if a - b - c - d == 7: print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7") return True else: return False for i in range(2): for j in range(2): for k in range(2): if plusminus(number, i, j, k): break break break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s259085285
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
def solve(S): for a in ['+', '-']: for b in ['+', '-']: for c in ['+', '-']: if eval('{}{}{}{}{}{}{}'.format( S[0], a, S[1], b, S[2], c, S[3] )) == 7: return '{}{}{}{}{}{}{}=7'.format( S[0], a, S[1], b, S[2], c, S[3] ) S = input() print(solve(S))
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s500040941
Accepted
p03545
Input is given from Standard Input in the following format: ABCD
N = input() OP = [ ["+", "+", "+"], ["-", "+", "+"], ["+", "-", "+"], ["+", "+", "-"], ["+", "-", "-"], ["-", "+", "-"], ["-", "-", "+"], ["-", "-", "-"], ] for op in OP: str = N[0] + op[0] + N[1] + op[1] + N[2] + op[2] + N[3] ans = eval(str) if ans == 7: print(str + "=7") break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s665858880
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
n = list(input()) ni = map(int, n) ns = sorted(ni, reverse=True) ans = 0 op = [] for i in ns: ans += i if ans > 7: ans -= i op += "-" else: op += "+" print("%d%s%d%s%d%s%d=7" % (ns[0], op[0], ns[1], op[1], ns[2], op[2], ns[3]))
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s921371653
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
n = int(input()) a = n // 1000 b = n // 100 - a * 10 c = n // 10 - a * 100 - b * 10 d = n - a * 1000 - b * 100 - c * 10 yet = True if a+b+c+d==7 and yet: print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7') yet = False if a+b+c-d==7 and yet: print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7') yet = False if a+b-c+d==7 and yet: print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7') yet = False if a+b-c-d==7 and yet: print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7') yet = False if a-b+c+d==7 and yet: print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7') yet = False if a-b+c-d==7 and yet: print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7') yet = False if a-b-c+d==7 and yet: print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7') yet = False if a-b-c-d==7 and yet: print(str(a)+'
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s062293721
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
def nyu(): N = list(map(str, input())) return N def check(LOP1, LOP2, LOP3): global flg1 ls = N[0] + LOP1 + N[1] + LOP2 + N[2] + LOP3 + N[3] if flg1 == True: return elif eval(ls) == 7: print(N[0], LOP1, N[1], LOP2, N[2], LOP3, N[3], "=7", sep="") flg1 = True return elif LOP1 == "-" and LOP2 == "-" and LOP3 == "-": flg1 = True print(-1) return if LOP1 == "+": check("-", LOP2, LOP3) if LOP2 == "+": check(LOP1, "-", LOP3) if LOP3 == "+": check(LOP1, LOP2, "-") N = nyu() flg1 = False OP1 = "+" OP2 = "+" OP3 = "+" check(OP1, OP2, OP3)
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s024544120
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
abcd = str(input()) abcd_list = list(abcd) a = int(abcd_list[0]) b = int(abcd_list[1]) c = int(abcd_list[2]) d = int(abcd_list[3]) ans2 = "+" ans3 = "+" ans4 = "+" for i in [a]: for j in [b, -b]: for k in [c, -c]: for l in [d, -d]: ans = i + j + k + l if ans == 7: if j < 0: ans2 = "-" elif k < 0: ans3 = "-" elif l < 0: ans4 = "-" print(str(a) + ans2 + str(b) + ans3 + str(c) + ans4 + str(d) + "=7")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s491590765
Wrong Answer
p03545
Input is given from Standard Input in the following format: ABCD
num = list(input()) print(num) ans = 7 for i in range(2 ** len(num)): total = 0 ans_num = [] ans_op = [] for j in range(len(num)): if (i >> j) & 1: ans_num.append(num[j]) if j >= 1: ans_op.append("+") total += int(num[j]) else: ans_num.append(num[j]) if j >= 1: ans_op.append("-") total -= int(num[j]) print(total) print(ans_op) if total == ans: print( ans_num[0] + ans_op[0] + ans_num[1] + ans_op[1] + ans_num[2] + ans_op[2] + ans_num[3] + "=7" ) break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s967470427
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
r = int(input()) a = r[0] b = r[1] c = r[2] d = r[3] if a+b+c+d ==7: print(a+"+"+b+"+"+c+"+"+d"=7") elif a+b+c-d ==7: print(a+"+"+b+"+"+c+"-"+d"=7") elif a+b-c+d ==7: print(a+"+"+b+"-"+c+"+"+d"=7") elif a+b-c-d ==7: print(a+"+"+b+"-"+c+"-"+d"=7") elif a-b+c+d ==7: print(a+"-"+b+"+"+c+"+"+d"=7") elif a-b+c-d ==7: print(a+"-"+b+"+"+c+"-"+d"=7") elif a-b-c+d ==7: print(a+"-"+b+"-"+c+"+"+d"=7") else: print(a+"-"+b+"-"+c+"-"+d"=7")
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]
Print the formula you made, including the part `=7`. Use the signs `+` and `-`. Do not print a space between a digit and a sign. * * *
s989887901
Runtime Error
p03545
Input is given from Standard Input in the following format: ABCD
n = int(input()) op_cnt = len(n)-1ใ€€#้š™้–“ใฎๆ•ฐ for i in range(2 ** op_cnt): op = ["-"]*op_cnt ##ใ‚ใ‚‰ใ‹ใ˜ใ‚[---]ใ‚’ๅ…ฅใ‚ŒใฆใŠใ for j in range(op_cnt): if ((i>>j)&1): op[op_cnt-1-j] = "+" #ใƒ•ใƒฉใƒ–ใŒ็ซ‹ใฃใฆใ„ใ‚‹็ฎ‡ๆ‰€ใ‚’"+"ใธ formula = "" for p_n,p_o in zip(n,op+[""]): formula += (p_n+p_o) if eval(formula) == 7: print(formula+ "=7") break
Statement Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
[{"input": "1222", "output": "1+2+2+2=7\n \n\nThis is the only valid solution.\n\n* * *"}, {"input": "0290", "output": "0-2+9+0=7\n \n\n0 - 2 + 9 - 0 = 7 is also a valid solution.\n\n* * *"}, {"input": "3242", "output": "3+2+4-2=7"}]