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最高),如果两个不同的节点有相同等级的父节点 ...
随机推荐
- cocos2d-x 3.0 rapidJson 解析操作应该注意的细节
Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstanc ...
- APlayer组件自制播放器
.NET中使用APlayer组件自制播放器 2015-02-02 09:46 by xiaozhi_5638, 402 阅读, 9 评论, 收藏, 编辑 目录 说明 APlayer介绍 APlayer ...
- Oralce 导出脚本命令,定时执行
原文:Oralce 导出脚本命令,定时执行 @echo off @echo ================================================ @echo window ...
- MongoDB的upsert状态判断和pymongo使用方法
在mongo中,有一个命令非常的方便,就是upsert,顾名思义就是update+insert的作用 根据条件判断有无记录,有的话就更新记录,没有的话就插入一条记录 upsert的使用方法: Mong ...
- 快速构建Windows 8风格应用22-MessageDialog
原文:快速构建Windows 8风格应用22-MessageDialog 本篇博文主要介绍MessageDialog概述.MessageDialog常用属性和方法.如何构建MessageDialog ...
- Asterisk 未来之路3.0_0006
原文:Asterisk 未来之路3.0_0006 Modules Asterisk 是基于模块构建的.一个模块提供某个特定的功能,它是动态的被装载.比如:信道驱动(chan_sip.so),或可以连接 ...
- leetcode第40题--First Missing Positive
题目: Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2 ...
- Python 3语法小记(九) 异常 Exception
常见异常: Exception 所有异常的基类 AttributeError 特性应用或赋值失败时引发 IOError ...
- 【工作笔记一】【转】Visual Studio 2012常用快捷键总结
Visual Studio 2012常用快捷键总结 原文 http://blog.csdn.net/yl2isoft/article/details/9886379 写在前面: 都知道,合理使用 ...
- selenium + python 部署自动化测试环境
选择selenium和python其实是怀有私心的:码两行python,熟悉熟悉. selenium优点很多,我最看重的是支持多语言,足够简单,同时支持浏览器. 实际工作中,简单实用真的太重要了 ...