Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into nteams and played several matches, two teams could not play against each other more than once.

The appointed Judge was the most experienced member — Pavel. But since he was the wisest of all, he soon got bored of the game and fell asleep. Waking up, he discovered that the tournament is over and the teams want to know the results of all the matches.

Pavel didn't want anyone to discover about him sleeping and not keeping an eye on the results, so he decided to recover the results of all games. To do this, he asked all the teams and learned that the real winner was friendship, that is, each team beat the other teams exactly ktimes. Help Pavel come up with chronology of the tournir that meets all the conditions, or otherwise report that there is no such table.

Input

The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).

Output

In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ nai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won against the team with number bi. You can assume, that the teams are numbered from 1 ton.

If a tournir that meets the conditions of the problem does not exist, then print -1.

Sample Input

Input
  1. 3 1
Output
  1. 3
    1 2
    2 3
    3 1

Source

很久之前做的题,输出所有的情况就行了。
  1. #include <iostream>
  2. #include <stdio.h>
  3. typedef long long LL;
  4. using namespace std;
  5. int main()
  6. {
  7. int i,n,m,k,j;
  8. cin>>n>>k;
  9. if (n-<*k)
  10. cout<<-<<endl;
  11. else
  12. {
  13. cout<<n*k<<endl;
  14. for (i=;i<=n;i++)
  15. {
  16. for (j=;j<k;j++)
  17. printf("%d %d\n",i,(i+j)%n+);
  18. }
  19. }
  20. return ;
  21. }

Codeforces 417 C的更多相关文章

  1. Codeforces 417 D. Cunning Gena

    按monitor排序,然后状压DP... . D. Cunning Gena time limit per test 1 second memory limit per test 256 megaby ...

  2. Codeforces Round #417 (Div. 2) D. Sagheer and Kindergarten(树中判祖先)

    http://codeforces.com/contest/812/problem/D 题意: 现在有n个孩子,m个玩具,每次输入x y,表示x孩子想要y玩具,如果y玩具没人玩,那么x就可以去玩,如果 ...

  3. Codeforces Round #417 (Div. 2) B. Sagheer, the Hausmeister

    http://codeforces.com/contest/812/problem/B 题意: 有n层楼,每层楼有m个房间,1表示灯开着,0表示灯关了.最两侧的是楼梯. 现在每从一个房间移动到另一个房 ...

  4. Codeforces Round #417 (Div. 2) B. Sagheer, the Hausmeister —— DP

    题目链接:http://codeforces.com/problemset/problem/812/B B. Sagheer, the Hausmeister time limit per test ...

  5. [Codeforces Round#417 Div.2]

    来自FallDream的博客,未经允许,请勿转载,谢谢. 有毒的一场div2 找了个1300的小号,结果B题题目看错没交  D题题目剧毒 E题差了10秒钟没交上去. 233 ------- A.Sag ...

  6. Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad

    [题意概述] 在一个十字路口 ,给定红绿灯的情况, 按逆时针方向一次给出各个路口的左转,直行,右转,以及行人车道,判断汽车是否有可能撞到行人 [题目分析] 需要在逻辑上清晰,只需要把所有情况列出来即可 ...

  7. Codeforces Round #417 (Div. 2) C. Sagheer and Nubian Market

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. Codeforces Round #417 C. Sagheer and Nubian Market

    C. Sagheer and Nubian Market time limit per test  2 seconds memory limit per test  256 megabytes   O ...

  9. Codeforces Round #417 B. Sagheer, the Hausmeister

    B. Sagheer, the Hausmeister time limit per test  1 second memory limit per test  256 megabytes   Som ...

随机推荐

  1. BZOJ-1407 Savage 枚举+拓展欧几里得(+中国剩余定理??)

    zky学长实力ACM赛制测试,和 大新闻(YveH) 和 华莱士(hjxcpg) 组队...2h 10T,开始 分工我搞A,大新闻B,华莱士C,于是开搞: 然而第一题巨鬼畜,想了40min发现似乎不可 ...

  2. 排序算法二(时间复杂度为O(N*logN))

    快速排序: 1 package test; public class QuickSort { // 快速排序 public void quickSort(int s[], int l, int r) ...

  3. POJ 2481Cows(树状数组 + 好题)

    Cows Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15222   Accepted: 5070 Description ...

  4. rwsr-sr-x类似权限设置

    如何设置suid/guid? 如果希望设置suid,那么就将相应的权限位之前的那一位设置为4:如果希望设置guid,那么就将相应的权限位之前的那一位设置为2:如果希望两者都置位,那么将相应的权限位之前 ...

  5. Javascript动态调整文章的行距、字体、颜色,及打印页面和关闭窗口功能

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. HDU4901 The Romantic Hero 计数DP

    2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/30 ...

  7. IE7 -- 鼠标移入显示下拉框 不显示的问题 / 以及宽度问题

    这个问题,真的是打击到我了,我一度不相信自己无法解决这个问题.但是我就是真的没有解决. 那么问题解决方案是: 第一 祖先级别有一个相对定位,父级再有一个定位,那么绝对定位显示出来的元素就会不显示. 第 ...

  8. UCloud可用区的设计理念及功能图文详解

    导读 过去的几个月内,UCloud对自身的云计算基础架构进行了全面升级,于日前宣布基础架构全面支持地域和可用区,并将可用区项目命名为Sixshot.通过这两层的设计架构来组织云服务,可以为用户提供高可 ...

  9. Unbuntu 下编译安装 PHP 必要库的安装

    2010/08/22 LINUX, PHP 2 COMMENTS 编译环境 sudo apt-get install build-essential xml sudo apt-get install ...

  10. BNUOJ 1037 精神控制

    XsuagrX喜欢到处唬人,各种唬.这不,经过刻苦修炼,他终于掌握了Bane Element的Ultra绝技加强版,恶魔掌控(快捷键F)(YY中&……).当XsugarX对某个人胡言乱语Q@# ...