Codeforces 417 C
| Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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 ≤ n; ai ≠ 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
3 1
3
1 2
2 3
3 1
Source
#include <iostream>
#include <stdio.h>
typedef long long LL;
using namespace std;
int main()
{
int i,n,m,k,j;
cin>>n>>k;
if (n-<*k)
cout<<-<<endl;
else
{
cout<<n*k<<endl;
for (i=;i<=n;i++)
{
for (j=;j<k;j++)
printf("%d %d\n",i,(i+j)%n+);
}
}
return ;
}
Codeforces 417 C的更多相关文章
- Codeforces 417 D. Cunning Gena
按monitor排序,然后状压DP... . D. Cunning Gena time limit per test 1 second memory limit per test 256 megaby ...
- Codeforces Round #417 (Div. 2) D. Sagheer and Kindergarten(树中判祖先)
http://codeforces.com/contest/812/problem/D 题意: 现在有n个孩子,m个玩具,每次输入x y,表示x孩子想要y玩具,如果y玩具没人玩,那么x就可以去玩,如果 ...
- Codeforces Round #417 (Div. 2) B. Sagheer, the Hausmeister
http://codeforces.com/contest/812/problem/B 题意: 有n层楼,每层楼有m个房间,1表示灯开着,0表示灯关了.最两侧的是楼梯. 现在每从一个房间移动到另一个房 ...
- 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 ...
- [Codeforces Round#417 Div.2]
来自FallDream的博客,未经允许,请勿转载,谢谢. 有毒的一场div2 找了个1300的小号,结果B题题目看错没交 D题题目剧毒 E题差了10秒钟没交上去. 233 ------- A.Sag ...
- Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad
[题意概述] 在一个十字路口 ,给定红绿灯的情况, 按逆时针方向一次给出各个路口的左转,直行,右转,以及行人车道,判断汽车是否有可能撞到行人 [题目分析] 需要在逻辑上清晰,只需要把所有情况列出来即可 ...
- 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 ...
- 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 ...
- Codeforces Round #417 B. Sagheer, the Hausmeister
B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes Som ...
随机推荐
- SpringMVC数据库链接池,以及其他相关配置
1.applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...
- JavaScript parser
JavaScript parser 和上面功能有点像,折叠JS代码,快速找到JS中类,方法的工具
- android 常见死机问题--log分析
http://blog.csdn.net/fangchongbory/article/details/7645815 android 常见死机问题--log分析============ ...
- The AndroidManifest.xml File
manifest (船运的)载货清单 http://www.android-doc.com/guide/topics/manifest/manifest-intro.html Every applic ...
- spring bean实例化方式
注意:xml配置中bean节点下scope属性默认值为singleton(单例),在需要多例的情况下需要配置成prototype spring提供三种实例化方式:默认构造.静态工厂.实例工厂 一.默认 ...
- 设定所有tableView中cell的分隔线颜色
上面只有针对xib或者storyboard中生成的tableview有效,如果想手码也有效,需在initwithframe中添加同样的方法
- 锋利的jQuery-7--编写插件基础知识
插件的基本要点: 1.命名推荐:jquery.[插件名].js,避免和其他js库插件混淆. 2.对象方法附加到:jQuery.fn上,全局函数附加到:jQuery对象本身. 3.在插件内部,this指 ...
- php闭包支持
匿名函数提到闭包就不得不想起匿名函数,也叫闭包函数(closures),貌似PHP闭包实现主要就是靠它.声明一个匿名函数是这样: $func = function() { }; //带结束符 可以看到 ...
- java分布式通信系统(J2EE分布式服务器架构)
一.序言 近几个月一直从事一个分布式异步通信系统,今天就整理并blog一下. 这是一个全国性的通信平台,对性能,海量数据,容错性以及扩展性有非常高的要求,所以在系统的架构上就不能简单的采用集中式.简单 ...
- [bug]The file ‘/xxx/xxx.aspx’ has not been pre-compiled, and cannot be requested
今天莫名奇妙的出现了这个问题,查找很多资料最后解决了. 发现编译的时候,少了一个dll,导致预编译失败. 参考资料 https://blogs.msdn.microsoft.com/asiatech/ ...