#include <bits/stdc++.h>
#define int long long
using namespace std;
#define endl '\n'
void work()
{
int n , k ; cin >> n >> k ;
if(k > n - 1)
{
cout << -1 << endl ;
return ;
}
else if(k == 1)
{
if(n == 1)
{
cout << -1 << endl ;
}
else if(n == 2)
{
cout << 1 << " " << 2 << endl ;
}
else
{
cout << -1 << endl ;
}
return ;
}
else
{
for(int i = 1 ; i <= k ; i++)
{
cout << i << " " << i + 1 << endl ;
}
if(n > k + 2)
{
for(int j = k + 2 ; j <= n ; j++)
{
cout << 2 << " " << j << endl ;
}
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--)
{
work();
}
return 0;
}
在这里补充一篇c++的题解

京公网安备 11010502036488号