| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 41435 | stevenyu | 【S】T2 | C++ | 解答错误 | 10 | 1350 MS | 252 KB | 1097 | 2026-04-22 21:34:51 |
#include<bits/stdc++.h> using namespace std; #define int long long int n,k; signed main(){ cin>>n>>k; if(!(n&1))return cout<<-1,0; int gcd=__gcd(n,k); if(gcd==1){ cout<<(n-1)/2<<endl; int cnt=n; int nw=0; while(cnt>1){ cout<<nw<<" "<<(nw+k)%n<<endl; cnt-=2; nw=(((nw+k)%n)+k)%n; } return 0; } else{ cout<<(n-1)/2<<endl; int nw=0; for(int i=1;i<=n/gcd;i++){ cout<<nw<<" "<<(nw+k)%n<<endl; nw=(((nw+k)%n)+k)%n; } for(int i=1;i<=(n/gcd)-1;i++){ if(i&1){ for(int j=(i-1)*gcd;2*j<=i*gcd-1;j++){ cout<<2*j<<" "<<2*j-1<<endl; } } else{ for(int j=(i-1)*gcd;2*j+1<=i*gcd-1;j++){ cout<<2*j<<" "<<2*j+1<<endl; } } } for(int i=((n/gcd)-1)*gcd;i+2<=n-1;i++){ cout<<i<<" "<<i+2<<endl; } } return 0; }