QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#645187#508. Nice sequencesyxsyx0 0ms3928kbC++14738b2024-10-16 17:12:082024-10-16 17:12:14

Judging History

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

  • [2024-10-16 17:12:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3928kb
  • [2024-10-16 17:12:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=200005,V=1e9;
int T;
int n,m;
bool tag;
int gcd(int x,int y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}
int res[N];
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&n,&m);
		if(n==m)
		{
			printf("%d\n",n-1);
			for(int i=1;i<n;i++) printf("1 ");
			printf("\n");
			continue;
		}
		if(n>m) swap(n,m),tag=1;
		else tag=0;
		int g=gcd(n,m);
		int len=n+m-1-g;
		printf("%d\n",len);
		n/=g;m/=g;
		int lim=V/(n+m-2);
		for(int i=1;i<=n+m-1;i++) res[i]=-lim;
		for(int i=n-1;i<=n+m-1;i+=n) res[i]=lim*(n-1)-1;
		if(tag) for(int i=1;i<=n+m-1;i++) res[i]=-res[i];
		for(int i=1;i<=len;i++) printf("%d ",res[i/g]);
		printf("\n");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 0ms
memory: 3928kb

input:

3
3 1
2 3
1 1

output:

2
1 1 
3
333333332 -333333333 333333332 
0


result:

ok Ok

Test #2:

score: 6
Accepted
time: 0ms
memory: 3924kb

input:

10
1 1
1 2
1 3
1 4
1 5
6 1
7 1
8 1
9 1
100 1

output:

0

1
-1 
2
-1 -1 
3
-1 -1 -1 
4
-1 -1 -1 -1 
5
1 1 1 1 1 
6
1 1 1 1 1 1 
7
1 1 1 1 1 1 1 
8
1 1 1 1 1 1 1 1 
99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok Ok

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3736kb

input:

10
60 1
70 1
1 60
1 70
1 50
39 1
41 1
23 1
1 99
87 3

output:

59
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
69
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
59
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer there is incorrect sequence

Subtask #2:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 3920kb

input:

10
2 2
3 2
4 2
5 2
2 6
2 7
2 8
9 2
10 2
2 11

output:

1
1 
3
-333333332 333333333 -333333332 
3
-1 1 1 
5
-199999999 200000000 -199999999 200000000 -199999999 
5
-1 -1 -1 -1 -1 
7
142857141 -142857142 142857141 -142857142 142857141 -142857142 142857141 
7
-1 -1 -1 -1 -1 -1 -1 
9
-111111110 111111111 -111111110 111111111 -111111110 111111111 -111111110 ...

result:

wrong answer there is incorrect sequence

Subtask #3:

score: 0
Wrong Answer

Test #24:

score: 14
Accepted
time: 0ms
memory: 3740kb

input:

10
7 1
1 5
1 1
10 1
1 4
3 1
1 6
1 2
1 9
8 1

output:

6
1 1 1 1 1 1 
4
-1 -1 -1 -1 
0

9
1 1 1 1 1 1 1 1 1 
3
-1 -1 -1 
2
1 1 
5
-1 -1 -1 -1 -1 
1
-1 
8
-1 -1 -1 -1 -1 -1 -1 -1 
7
1 1 1 1 1 1 1 

result:

ok Ok

Test #25:

score: 0
Wrong Answer
time: 0ms
memory: 3832kb

input:

10
6 2
2 4
2 2
2 5
3 2
7 2
2 10
2 1
2 8
2 9

output:

5
-1 1 1 1 1 
3
-1 -1 -1 
1
1 
5
199999999 -200000000 199999999 -200000000 199999999 
3
-333333332 333333333 -333333332 
7
-142857141 142857142 -142857141 142857142 -142857141 142857142 -142857141 
9
-1 -1 -1 -1 -1 -1 -1 -1 -1 
1
1 
7
-1 -1 -1 -1 -1 -1 -1 
9
111111110 -111111111 111111110 -111111111...

result:

wrong answer there is incorrect sequence

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 0ms
memory: 3844kb

input:

10
2 3
2 4
4 3
5 3
5 4
6 4
6 5
5 7
7 6
6 8

output:

3
333333332 -333333333 333333332 
3
-1 -1 -1 
5
200000000 -399999999 200000000 200000000 -399999999 
6
166666666 -333333331 166666666 166666666 -333333331 166666666 
7
142857142 142857142 -428571425 142857142 142857142 142857142 -428571425 
7
-1 -333333332 -333333332 333333333 333333333 -333333332 -...

result:

wrong answer there is incorrect sequence

Subtask #5:

score: 0
Skipped

Dependency #3:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%