其他分享
首页 > 其他分享> > CodeForces - 417C Football

CodeForces - 417C Football

作者:互联网

在这里插入图片描述

会卡cout!!!!!
第一个是cin +printf
第二个是scanf + printf
cout会T,,,比赛卡了1小时,自闭
在这里插入图片描述
水题,需要用 组合数判断一下

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 7;
int n, k;
int book[N];
int flag = 0;
int main() {
    scanf("%d %d", &n, &k);
    if((k * n) > (n * (n - 1) / 2))
        printf("-1\n");
    else {
        printf("%d\n", n * k);
        int i = 1, j = 2, ans = 1;
        for(; ans <= k; ans++, j++) {
            book[flag++] = i;
            book[flag++] = j;
        }
        for(i = flag; i < n * k * 2; i += 2) {
            book[i] = book[i - flag] + 1;
            book[i + 1] = book[i + 1 - flag] + 1;
            if(book[i + 1] > n)
                book[i + 1] -= n;
        }
        for(i = 0; i < n * k * 2; i += 2)
            printf("%d %d\n", book[i], book[i + 1]);
    }
    return 0;
}

标签:417C,cout,int,scanf,Football,CodeForces,book,ans,printf
来源: https://blog.csdn.net/weixin_43879181/article/details/95867343