QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785471#9799. Magical PaletteMENDAXRE 0ms0kbC++201.0kb2024-11-26 18:02:122024-11-26 18:02:35

Judging History

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

  • [2024-11-26 18:02:35]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-26 18:02:12]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
#define endl '\n'

using namespace std;
const int N = 1e4 + 10,INF=1e9+10;

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

void solve() {
	int n,m;
	cin>>n>>m;
	if(gcd(n,m)!=1){
		cout<<"No"<<endl;
	}
	else {
		cout<<"Yes"<<endl;
		if(n==1&&m==1){
			cout<<0<<endl;
			cout<<0<<endl;
		}
		else if(n==1){
			cout<<1<<endl;
			for(int i=0;i<m;i++)cout<<i<<" ";
			cout<<endl;
		}
		else if(m==1){
			for(int i=0;i<n;i++)cout<<i<<" ";
			cout<<endl;
			cout<<1<<endl;
		}else if(n<m){
			for(int i=1;i<=n;i++)cout<<i<<" ";
			cout<<endl;
			int no=1;
			for(int i=1;i<=m;i++){
				cout<<no<<" ";
				assert(no>=n*m);
				no+=n;
			}
			cout<<endl;
		}
		else{
			int no=1;
			for(int i=1;i<=n;i++){
				cout<<no<<" ";
				assert(no>=n*m);
				no+=m;
			}
			cout<<endl;
			for(int i=1;i<=m;i++)cout<<i<<" ";
			cout<<endl;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	int T;cin >> T;
	while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

2
2 3
2 2

output:


result: