CF 322A Ciel and Dancing 好简单的题。。最喜欢水题了
1 second
256 megabytes
standard input
standard output
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:
- either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);
- or the girl in the dancing pair must dance for the first time.
Help Fox Ciel to make a schedule that they can dance as many songs as possible.
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.
In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.
- 2 1
- 2
- 1 1
- 2 1
- 2 2
- 3
- 1 1
- 1 2
- 2 2
In test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).
And in test case 2, we have 2 boys with 2 girls, the answer is 3.
题目意思是跳舞的满足2个条件,要么男的是第一次,要么女的是第一次。那答案很显然就是 n+m-1。
n+m-1
1 1
1 2
1 3
...
1 m
2 1
3 1
...
n 1
- /*
- * @author ipqhjjybj
- * @date 20130711
- *
- */
- #include <cstdio>
- #include <cstdlib>
- int main(){
- int n,m;
- scanf("%d %d",&n,&m);
- printf("%d\n",n+m-1);
- for(int i = 1;i<=m;i++){
- printf("1 %d\n",i);
- }
- for(int i = 2;i<=n;i++){
- printf("%d 1\n",i);
- }
- return 0;
- }
CF 322A Ciel and Dancing 好简单的题。。最喜欢水题了的更多相关文章
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
题意:给你许多串字符串,从中提取电话号码,输出出现复数次的电话号码及次数. 以下是我艰难的AC历程:(这题估计是我刷的题目题解次数排前的了...) 题目不是很难理解,刚开始想到用map,但stl的ma ...
- CF 628C --- Bear and String Distance --- 简单贪心
CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符 ...
- CF 628A --- Tennis Tournament --- 水题
CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...
- 一道cf水题再加两道紫薯题的感悟
. 遇到一个很大的数除以另一个数时,可以尝试把这个很大的数进行,素数因子分解. . 遇到多个数的乘积与另一个数的除法时,求是否能整除,可以先求每一个数与分母的最大公约数,最后若分母数字为1,则证明可整 ...
- CF 628B New Skateboard --- 水题
CD 628B 题目大意:给定一个数字(<=3*10^5),判断其能被4整除的连续子串有多少个 解题思路:注意一个整除4的性质: 若bc能被4整除,则a1a2a3a4...anbc也一定能被4整 ...
- ytu 1304:串的简单处理(水题)
串的简单处理 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 39 Solved: 11[Submit][Status][Web Board] Desc ...
- 做了一道cf水题
被一道cf水题卡了半天的时间,主要原因时自己不熟悉c++stl库的函数,本来一个可以用库解决的问题,我用c语言模拟了那个函数半天,结果还超时了. 题意大概就是,给定n个数,查询k次,每次查询过后,输出 ...
- CF 120F Spider 树的直径 简单题
一个男孩有n只玩具蜘蛛,每只蜘蛛都是一个树的结构,现在男孩准备把这n只小蜘蛛通过粘贴节点接在一起,形成一只大的蜘蛛.大的蜘蛛也依然是树的结构.输出大的蜘蛛的直径. 知识: 树的直径是指树上的最长简单路 ...
- CF 322E - Ciel the Commander 树的点分治
树链剖分可以看成是树的边分治,什么是点分治呢? CF322E - Ciel the Commander 题目:给出一棵树,对于每个节点有一个等级(A-Z,A最高),如果两个不同的节点有相同等级的父节点 ...
随机推荐
- phpstorm安装laravel-ide-helper实现自动完成、代码提示和跟踪
本文讲述laravel-ide-helper的安装方法.phpstorm安装了laravel-ide-helper后可以实现代码提示.跟踪和自动补全,减少查看API文档的次数,提高开发效率. lara ...
- linux下的watch命令
linux下的watch命令 在linux下,watch是周期性的执行下一个命令,并全屏显示执行结果. watch [-dhvt] [-n <seconds>] [--difference ...
- Visual Studio 如何给生成的exe加入多个图标资源
Visual Studio 如何给生成的exe加入多个图标资源(快捷方式可调用) 方法: 打开你的VS, 文件—>新建—>文件 常规—>选择本机资源模板(rct文件) 如图一 新建后 ...
- Linux - 命令行 管道(Pipelines) 详细解释
命令行 管道(Pipelines) 详细解释 本文地址: http://blog.csdn.net/caroline_wendy/article/details/24249529 管道操作符" ...
- Codeforces 10D LCIS 找出最长公共子和产量增加这个序列 dp
主题链接:点击打开链接 意甲冠军: 特定n长序列 给定k长序列 求LCIS并输出这个子序列 如有多解输出随意解.. = - = 敲的时候听着小曲儿pre的含义还没有想清楚,万万没想到就过了... #i ...
- 在C#中Color结构的各属性颜色对照表(转)
转自:http://blog.sina.com.cn/s/blog_454dc49501016q2p.html Color.AliceBlue 240,248,255 Color.LightSalmo ...
- 面试必须要知道的SQL语法,语句
面试必须要知道的SQL语法,语句 收藏 asc 按升序排列desc 按降序排列下列语句部分是Mssql语句,不可以在access中使用.SQL分类: DDL—数据定义语言(Create,Alter,D ...
- VS2012下systemC配置
一.编译System库 1.下载SystemC library source code 到http://www.systemc.org注册会员账号后,即可下载SystemC ...
- 刚下载的几个开源的Android项目
Android-Universal-Image-Loader Android上最让人头疼的莫过于从网络获取图片.显示.回收,任何一个环节有问题都可能直接OOM,这个项目或许能帮到你. Universa ...
- mvc3项目如何在IIS7.5上发布的
若项目拿到服务器上发布,必须要安装MVC3的安装包! 1.在vs中打开你要发布的项目,右键属性找到发布 2.弹出发布web对话框,选择<新建配置文件...> 在弹出的对话框中输入一个配置文 ...