#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORR(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTR(i,a,b) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define gcd __gcd
#define fr first
#define sc second
#define x real
#define y imag
typedef long long ll;
typedef long double ld;
const int N = 4e5+6;
const int K = 406;
int pref[N],timer=1;
int n,m,qan;
void dfs(int v){
if (v-n>=0 && !pref[v-n])dfs(v-n);
if (v+m<=qan && !pref[v+m])dfs(v+m);
pref[v]=timer++;
}
int main(){
ios_base::sync_with_stdio(false);
int t;
cin>>t;
assert(t==3);
while(t--){
cin>>m>>n;
assert((m==3 && n==1) || (m==2 && n==3) || (m==1 && n==1));
qan=n+m-1-gcd(n,m);
cout<<qan<<endl;
FORT(i,1,qan){
if (!pref[i])dfs(i);
}
FORT(i,1,qan){
cout<<pref[i]-pref[i-1]<<" ";
pref[i-1]=0;
}
pref[qan]=0;
timer=1;
cout<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |