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最高),如果两个不同的节点有相同等级的父节点 ...
随机推荐
- datatables表格
datatables表格 并不是所有的后台开发都有美工和前端工程师来配合做页面,为了显示数据并有一定的美感,jQuery的DataTables插件对于像我这样的前端菜鸟来说真是雪中送炭,当然对于专业的 ...
- view components介绍
view components介绍 在ASP.NET MVC 6中,view components (VCs) 功能类似于虚拟视图,但是功能更加强大. VCs兼顾了视图和控制器的优点,你可以把VCs ...
- MVC+Jqgrid
基于MVC+Jqgrid的列表页面 2014-12-08 12:01 by 刘尼玛, 1583 阅读, 20 评论, 收藏, 编辑 一.前言 “尼玛哥,上周你教我改了下OA系统UI,黄总看了很满意呀. ...
- 【通过操作指针,与指针做函数參数'实现字串在主串中出现的次数,然后将出现的部分依照要求进行替换
】
#include<stdio.h> #include<stdlib.h> int strTime(const char *str1, const char *str2, int ...
- windows系统SVN和apache的下载和安装
原文:windows系统SVN和apache的下载和安装 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://ejb3.blogbus.com/logs/107443052. ...
- bitnami redmine安装、配置、备份、恢复(这篇文章靠谱)
bitnami redmine安装.配置.备份.恢复 2012-12-17 12:33 2596人阅读 评论(0) 收藏 举报 1. 安装时语言选择英文,不可以选择中文,否则不能正常运行,可以在账户里 ...
- jquery扩展方法案例
-----------------扩展方法: $.extend({ "max": function (a, b) { if (a > b) return a; }, &quo ...
- Asp.net MVC的Model Binder工作流程以及扩展方法(1)
Asp.net MVC的Model Binder工作流程以及扩展方法(1)2014-03-19 08:02 by JustRun, 523 阅读, 4 评论, 收藏, 编辑 在Asp.net MVC中 ...
- DesignMode的状态处理
自定义控件开发的调试及DesignMode的状态处理 在开发Winform程序的时候,我们往往需要根据需要做一些自定义的控件模块,这样可以给系统模块重复利用,或者实现更好的效果等功能.但在使用的时候, ...
- C/S应用升级更新完整解决方案
年末福利,C/S应用升级更新完整解决方案放送 程序员,工作累寿命短,大家应该学会分享,别浪费有限的生命与健康做重复的事情. C/S方式实现的应用有个升级更新功能是必需的,以前整过一个但是没考虑多套C/ ...