QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#512081#9167. Coprime Arrayucup-team2818#WA 0ms3692kbC++141.0kb2024-08-10 13:28:022024-08-10 13:28:04

Judging History

This is the latest submission verdict.

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 13:28:04]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3692kb
  • [2024-08-10 13:28:02]
  • Submitted

answer

#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;
ll m[15], c[15];

ll x, y;

ll exgcd(ll a, ll b)
{
	if (!b)
	{
		x = 1, y = 0;
		return a;
	}
	ll d = exgcd(b, a % b);
	ll tmp = x;
	x = y;
	y = tmp - (a / b) * y;
	return d;
}

int main()
{
	int n = 0;
	int s, t;
	cin >> s >> t;
	
	bool Fl = 0;
	if ((s & 1) && !(t & 1)) Fl = 1, s--;
	
	for (int i = 2; i * i <= t; i++)
		if (t % i == 0)
		{
			m[++n] = i;
			if (s % i == 0) c[n] = 1;
			else if (s % i == 1) c[n] = i - 1;
			else c[n] = 1;
			while (t % i == 0) t /= i;
		}
	if (t > 1)
	{
		m[++n] = t;
		if (s % t == 0) c[n] = 1;
		else if (s % t == 1) c[n] = t - 1;
		else c[n] = 1;
	}
	
	ll M = 1, ans = 0;
	for (int i = 1; i <= n; i++) M *= m[i];
	for (int i = 1; i <= n; i++)
	{
		ll a = M / m[i], b = m[i];
		ll gcd = exgcd(a, b);
		if (x < 0) x += b;
		ans += a * x * c[i];
	}
	ans %= M;
	
	if (!Fl) cout << "2\n" << ans << " " << s - ans;
	else cout << "3\n1 " << ans << " " << s - ans;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

9 6

output:

3
1 1 7

result:

ok Correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

14 34

output:

2
1 13

result:

ok Correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

1000000000 223092870

output:

2
148728581 851271419

result:

ok Correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

2 1000000000

output:

2
1 1

result:

ok Correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

649557664 933437700

output:

2
83981 649473683

result:

ok Correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

33396678 777360870

output:

2
1 33396677

result:

ok Correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

48205845 903124530

output:

3
1 6271 48199573

result:

ok Correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

251037078 505905400

output:

2
1 251037077

result:

ok Correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

30022920 172746860

output:

2
1 30022919

result:

ok Correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

63639298 808058790

output:

2
248711 63390587

result:

ok Correct

Test #11:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

76579017 362768406

output:

3
1 1 76579015

result:

ok Correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

40423669 121437778

output:

3
1 1 40423667

result:

ok Correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

449277309 720915195

output:

2
1 449277308

result:

ok Correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

81665969 919836918

output:

3
1 68069 81597899

result:

ok Correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

470578680 280387800

output:

2
1 470578679

result:

ok Correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

58450340 803305503

output:

2
1 58450339

result:

ok Correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

125896113 323676210

output:

3
1 44461 125851651

result:

ok Correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

381905348 434752500

output:

2
1 381905347

result:

ok Correct

Test #19:

score: -100
Wrong Answer
time: 0ms
memory: 3672kb

input:

78916498 653897673

output:

2
33593 78882905

result:

wrong answer Jury's answer is better than participant's