#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int big=1e9;
int main()
{
int T,N,M,i;
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&N,&M);
if(max(N,M)%min(N,M)==0)
{
if(N>M)
{
printf("%d\n",N-1);
for(i=0;i<N-1;i++) printf("1 ");
printf("\n");
}
else
{
printf("%d\n",M-1);
for(i=0;i<M-1;i++) printf("-1 ");
printf("\n");
}
}
else if(N==2)
{
if(M%2==0) M--;
printf("%d\n",M);
for(i=0;i<M;i++)
{
if(i%2==0) printf("%d ",big-1);
else printf("%d ",0-big);
}
printf("\n");
}
else if(M==2)
{
if(N%2==0) N--;
printf("%d\n",N);
for(i=0;i<N;i++)
{
if(i%2==0) printf("%d ",0-big+1);
else printf("%d ",big);
}
printf("\n");
}
else if(N-M==1||N-M==2)
{
printf("%d\n",N);
printf("%d ",0-big/10*9);
for(i=0;i<M-2;i++) printf("%d ",big/(M-2));
printf("%d ",0-big/10*9);
printf("\n");
}
else if(M-N==1||M-N==2)
{
printf("%d\n",M);
printf("%d ",big/10*9);
for(i=0;i<M-2;i++) printf("%d ",0-big/(M-2));
printf("%d ",big/10*9);
printf("\n");
}
}
return 0;
}
Compilation message
sequence.cpp: In function 'int main()':
sequence.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
10 | scanf("%d",&T);
| ~~~~~^~~~~~~~~
sequence.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
13 | scanf("%d %d",&N,&M);
| ~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
9 |
Correct |
1 ms |
364 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
1 ms |
364 KB |
Ok |
12 |
Correct |
1 ms |
364 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
2 ms |
364 KB |
Ok |
7 |
Correct |
8 ms |
876 KB |
Ok |
8 |
Correct |
4 ms |
620 KB |
Ok |
9 |
Correct |
9 ms |
1004 KB |
Ok |
10 |
Correct |
5 ms |
748 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
0 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Incorrect |
1 ms |
364 KB |
Jury has the better answer : jans = 9, pans = 2 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Jury has the better answer : jans = 5, pans = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
9 |
Correct |
1 ms |
364 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
1 ms |
364 KB |
Ok |
12 |
Correct |
1 ms |
364 KB |
Ok |
13 |
Correct |
1 ms |
364 KB |
Ok |
14 |
Correct |
0 ms |
364 KB |
Ok |
15 |
Correct |
1 ms |
364 KB |
Ok |
16 |
Incorrect |
1 ms |
364 KB |
Jury has the better answer : jans = 9, pans = 2 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
9 |
Correct |
1 ms |
364 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
1 ms |
364 KB |
Ok |
12 |
Correct |
1 ms |
364 KB |
Ok |
13 |
Correct |
0 ms |
364 KB |
Ok |
14 |
Correct |
1 ms |
364 KB |
Ok |
15 |
Correct |
1 ms |
364 KB |
Ok |
16 |
Correct |
1 ms |
364 KB |
Ok |
17 |
Correct |
1 ms |
364 KB |
Ok |
18 |
Correct |
2 ms |
364 KB |
Ok |
19 |
Correct |
8 ms |
876 KB |
Ok |
20 |
Correct |
4 ms |
620 KB |
Ok |
21 |
Correct |
9 ms |
1004 KB |
Ok |
22 |
Correct |
5 ms |
748 KB |
Ok |
23 |
Correct |
1 ms |
364 KB |
Ok |
24 |
Correct |
0 ms |
364 KB |
Ok |
25 |
Correct |
1 ms |
364 KB |
Ok |
26 |
Incorrect |
1 ms |
364 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
9 |
Correct |
1 ms |
364 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
1 ms |
364 KB |
Ok |
12 |
Correct |
1 ms |
364 KB |
Ok |
13 |
Correct |
0 ms |
364 KB |
Ok |
14 |
Correct |
1 ms |
364 KB |
Ok |
15 |
Correct |
1 ms |
364 KB |
Ok |
16 |
Correct |
1 ms |
364 KB |
Ok |
17 |
Correct |
1 ms |
364 KB |
Ok |
18 |
Correct |
2 ms |
364 KB |
Ok |
19 |
Correct |
8 ms |
876 KB |
Ok |
20 |
Correct |
4 ms |
620 KB |
Ok |
21 |
Correct |
9 ms |
1004 KB |
Ok |
22 |
Correct |
5 ms |
748 KB |
Ok |
23 |
Correct |
1 ms |
364 KB |
Ok |
24 |
Correct |
0 ms |
364 KB |
Ok |
25 |
Correct |
1 ms |
364 KB |
Ok |
26 |
Incorrect |
1 ms |
364 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |