CodeForces - 417C Football

CodeForces - 417C  Football

会卡cout!!!!!
第一个是cin +printf
第二个是scanf + printf
cout会T,,,比赛卡了1小时,自闭
CodeForces - 417C  Football
水题,需要用 组合数判断一下

#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;
}
上一篇:删除多余的自编译的内核、mysql连接不了的问题


下一篇:Oracle EBS-SQL (PO-4):检查采购订单明细.sql