QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#514297#9167. Coprime Arrayucup-team3695#TL 15ms10712kbPython3421b2024-08-11 00:14:302024-08-11 00:14:30

Judging History

你现在查看的是最新测评结果

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-11 00:14:30]
  • 评测
  • 测评结果:TL
  • 用时:15ms
  • 内存:10712kb
  • [2024-08-11 00:14:30]
  • 提交

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

output:


result: