QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#513727#9167. Coprime Arrayucup-team4504#TL 0ms3648kbC++17780b2024-08-10 19:18:242024-08-10 19:18:25

Judging History

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

  • [2024-08-11 17:38:28]
  • hack成功,自动添加数据
  • (/hack/775)
  • [2024-08-10 19:18:25]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3648kb
  • [2024-08-10 19:18:24]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, m;
int top, sta[100000];
void dfs(int d, int de){
	if (de == d){
		cout << de << endl;
		for (int i = 0; i < top; i++) cout << sta[i] << ' ';
		exit(0);
		return;
	}
	if (de + 1 == d){
		int sum = 0;
		for (int i = 0; i < top; i++) sum += sta[i];
		sta[top] = n - sum;
		top++;
		if (__gcd(abs(sta[top - 1]), m) == 1) dfs(d, de + 1);
		top--;
	}else
		for (int i = 0; i < m; i++)
			if (__gcd(i, m) == 1){
				sta[top] = i;
				top++;
				dfs(d, de + 1);
				top--;
			}
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	cin >> n >> m;
	int x = 2;
	while (1) dfs(x, 0), x++;
	return 0;
}

詳細信息

Test #1:

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

input:

9 6

output:

3
1 1 7 

result:

ok Correct

Test #2:

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

input:

14 34

output:

2
1 13 

result:

ok Correct

Test #3:

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

input:

1000000000 223092870

output:

2
29 999999971 

result:

ok Correct

Test #4:

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

input:

2 1000000000

output:

2
1 1 

result:

ok Correct

Test #5:

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

input:

649557664 933437700

output:

2
11 649557653 

result:

ok Correct

Test #6:

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

input:

33396678 777360870

output:

2
1 33396677 

result:

ok Correct

Test #7:

score: -100
Time Limit Exceeded

input:

48205845 903124530

output:


result: