A. Heads or Tails
来源:互联网 发布:Mac Miller 编辑:程序博客网 时间:2024/05/18 02:05
Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the end of the game. If boys have the same number of points, the game finishes with a draw.
At some point, Valera lost his count, and so he can not say exactly what the score is at the end of the game. But there are things he remembers for sure. He remembers that the entire game Vasya got heads at least a times, and Petya got heads at least b times. Moreover, he knows that the winner of the game was Vasya. Valera wants to use this information to know every possible outcome of the game, which do not contradict his memories.
The single line contains four integers x, y, a, b (1 ≤ a ≤ x ≤ 100, 1 ≤ b ≤ y ≤ 100). The numbers on the line are separated by a space.
In the first line print integer n — the number of possible outcomes of the game. Then on n lines print the outcomes. On the i-th line print a space-separated pair of integers ci, di — the number of heads Vasya and Petya got in the i-th outcome of the game, correspondingly. Print pairs of integers (ci, di) in the strictly increasing order.
Let us remind you that the pair of numbers (p1, q1) is less than the pair of numbers (p2, q2), if p1 < p2, or p1 = p2 and alsoq1 < q2.
3 2 1 1
32 13 13 2
2 4 2 2
0
解题说明:暴力,双重循环加个判断即可
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int main(){int x,y,a,b;int count,i,j,k;int c[10001],d[10001];scanf("%d %d %d %d",&x,&y,&a,&b);count=0;k=0;if(a<=b){a=b+1;}for(i=a;i<=x;i++){for(j=b;j<=y;j++){if(i>j){count++;c[k]=i;d[k]=j;k++;}else{break;}}}printf("%d\n",count);for(i=0;i<count;i++){printf("%d %d\n",c[i],d[i]);}return 0;}
- A. Heads or Tails
- codeforces-242A-Heads or Tails【暴力】
- UVa 474 - Heads / Tails Probability
- Heads / Tails Probability FrUVA, 474
- UVA 474 - Heads / Tails Probability(递推)
- uva 474 - Heads / Tails Probability(递推)
- Our tails
- UVA_474_Heads / Tails Probability
- Conundrum:What has two heads, four eyes, six legs and a tail?
- 扫盲Tails操作系统(一)
- A Stack or A Queue?
- A Stack or A Queue?
- A Stack or A Queue?
- A Stack or A Queue?
- A Stack or A Queue?
- A Stack or A Queue?
- A or An?
- A. Boy or Girl
- 介绍一个 C/C++ 、C#、JAVA 代码美化工具
- boost::asio一个简单的echo服务器
- RMAN-06054错误解决办法
- HDU1789--Doing Homework again
- Failed to create the Java Virtual Machine 的解决方案
- A. Heads or Tails
- 测电源的纹波电压纹波系数
- test
- 10192 - Vacation
- SERVER SQL 2003服务器 升到到SERVER SQL 2008
- 大话存储系列20——数据存储与数据管理综述
- Java Web分类考点总结——Struts2
- 转 CRT 上传 下载
- 物联网的概念及其外延