题意(题意很重要):
1.n个足球队伍,每个队伍赢得k场比赛
2.输出比赛次数以及每次的胜负方。
3.如果没有满足的情况就输出-1
思路:
1.先看n和k是否满足情况,每个人最多可以赢n-1次,所以n-1一定大于等于k,否则就会有重复的胜负方出现
2.输出很宽松(cf的数据就是强)
悲催的没有理解好题意,-1没判断好。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int n,k;
cin >> n >> k;
if((n-1)/2 < k)
return 0*printf("-1\n");
printf("%d\n",n*k);
for(int kk = 1;kk <= k;kk++)
{
for(int i = 1;i <= n;i++)
{
printf("%d ",i);
if((i + kk) % n != 0)
printf("%d\n",(i+kk)%n);
else
printf("%d\n",n);
}
}
return 0;
}