QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#514297 | #9167. Coprime Array | ucup-team3695# | TL | 15ms | 10712kb | Python3 | 421b | 2024-08-11 00:14:30 | 2024-08-11 00:14:30 |
Judging History
answer
from math import gcd
import sys
input=lambda:sys.stdin.readline().strip()
a,b=map(int,input().split())
c=a%b
def fin(l):
t=sum(l)
assert(t%b==c)
l[0]+=a-t
print(len(l))
print(*l)
if c==0:
print(-1)
exit()
if gcd(c,b)==1:
print(a)
exit()
for o in range(b):
if o>0 and gcd(b,o)!=1:continue
g=(c-o-1)%b
if gcd(g,b)==1:
if o==0:fin([1,g])
else:fin([g,o,1])
exit()
print(-1)
詳細信息
Test #1:
score: 100
Accepted
time: 15ms
memory: 10712kb
input:
9 6
output:
3 7 1 1
result:
ok Correct
Test #2:
score: 0
Accepted
time: 8ms
memory: 10704kb
input:
14 34
output:
2 1 13
result:
ok Correct
Test #3:
score: -100
Time Limit Exceeded
input:
1000000000 223092870