#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;
while(t--){
cin>>m>>n;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
296 KB |
Ok |
2 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |