A. Ciel and Dancing
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.

Output

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.

Sample test(s)
input
2 1
output
2
1 1
2 1
input
2 2
output
3
1 1
1 2
2 2
Note

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 好简单的题。。最喜欢水题了的更多相关文章

  1. POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题

    题意:给你许多串字符串,从中提取电话号码,输出出现复数次的电话号码及次数. 以下是我艰难的AC历程:(这题估计是我刷的题目题解次数排前的了...) 题目不是很难理解,刚开始想到用map,但stl的ma ...

  2. CF 628C --- Bear and String Distance --- 简单贪心

    CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符 ...

  3. CF 628A --- Tennis Tournament --- 水题

    CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...

  4. 一道cf水题再加两道紫薯题的感悟

    . 遇到一个很大的数除以另一个数时,可以尝试把这个很大的数进行,素数因子分解. . 遇到多个数的乘积与另一个数的除法时,求是否能整除,可以先求每一个数与分母的最大公约数,最后若分母数字为1,则证明可整 ...

  5. CF 628B New Skateboard --- 水题

    CD 628B 题目大意:给定一个数字(<=3*10^5),判断其能被4整除的连续子串有多少个 解题思路:注意一个整除4的性质: 若bc能被4整除,则a1a2a3a4...anbc也一定能被4整 ...

  6. ytu 1304:串的简单处理(水题)

    串的简单处理 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 39  Solved: 11[Submit][Status][Web Board] Desc ...

  7. 做了一道cf水题

    被一道cf水题卡了半天的时间,主要原因时自己不熟悉c++stl库的函数,本来一个可以用库解决的问题,我用c语言模拟了那个函数半天,结果还超时了. 题意大概就是,给定n个数,查询k次,每次查询过后,输出 ...

  8. CF 120F Spider 树的直径 简单题

    一个男孩有n只玩具蜘蛛,每只蜘蛛都是一个树的结构,现在男孩准备把这n只小蜘蛛通过粘贴节点接在一起,形成一只大的蜘蛛.大的蜘蛛也依然是树的结构.输出大的蜘蛛的直径. 知识: 树的直径是指树上的最长简单路 ...

  9. CF 322E - Ciel the Commander 树的点分治

    树链剖分可以看成是树的边分治,什么是点分治呢? CF322E - Ciel the Commander 题目:给出一棵树,对于每个节点有一个等级(A-Z,A最高),如果两个不同的节点有相同等级的父节点 ...

随机推荐

  1. 天体程序猿叹息——变化hosts对

    没有解释更新一SDK像贼,我真诚地希望在天上Android.ios我们已经禁止了.要玩不能玩才最寂寞 安装成功不寂寞hosts文件: 74.125.237.1 dl-ssl.google.com173 ...

  2. 使用Dropbox+Justwriting+Markdown建立个人博客

    使用Dropbox+Justwriting+Markdown建立个人博客,让您真正体会到什么是"简化". 您的博客所有日志存储在您的PC上.即使有一天你的server主机挂了,你的 ...

  3. ActionScript GifPlayer的修改

    ActionScript不能播放gif格式的图片,在做as项目的时候如果需要用到加载gif动画图片时,就需要引入第三方包. 常用的第三方包是GifPlayer,在github上可以找到该项目的源代码C ...

  4. 【UVA】10285-Longest Run on a Snowboard(动态规划)

    这是一个简单的问题.你并不需要打印路径. 状态方程dp[i][j] = max(dp[i-1][j],dp[i][j-1],dp[i+1][j],dp[i][j+1]); 14003395 10285 ...

  5. 在vi中使用perltidy格式化perl代码

    格式优美的perl代码不但让人赏心悦目,并且能够方便阅读. perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂美丽亮,快来体验一下吧!! ...

  6. Mybatis之动态构建SQL语句

    今天一个新同事问我,我知道如何利用XML的方式来构建动态SQL,可是Mybatis是否能够利用注解完成动态SQL的构建呢?!!答案是肯定的,MyBatis 提供了注解,@InsertProvider, ...

  7. SSIS中执行SQL任务组件参数传递的问题

    原文:SSIS中执行SQL任务组件参数传递的问题 症状: 执行SQL任务,传递参数到子查询中,执行报错. 错误: 失败,错误如下:"无法从使用 sub-select 查询的 SQL 语句中派 ...

  8. js实现在新标签页打开页面

    这种方法打开新标签页要在IE9+以上浏览器才可以! <html> <head> <meta http-equiv="Content-type" con ...

  9. vector成员函数解析

    vector线性集装箱,其元素颜格排序根据线性序列,和动态数组很阶段似,像阵列,它的元素被存储在连续的存储空间,这也意味着,我们不仅能够使用迭代器(iterator)访问元素,也可以用一个指针访问偏移 ...

  10. SQLSever: 如何在select中的每一行产生不同的随机数?

    原文:SQLSever: 如何在select中的每一行产生不同的随机数? select 的随机函数有点假, 也许是因为它是基于时间来的吧, 同一select中由于时间无法错开导致产生的随机数都是一样的 ...