Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coinXTimes,
Then Petya tosses a coinYTimes. 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 leastATimes,
And Petya got heads at leastBTimes. 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.
Input
The single line contains four IntegersX, Bytes,Y, Bytes,A, Bytes,B(1 digit ≤ DigitALimit ≤ limitXLimit ≤ limit 100, limit 1 limit ≤ limitBLimit ≤ limitYLimit ≤ limit 100 ).
The numbers on the line are separated by a space.
Output
In the first line print integerN-The number of possible outcomes of the game. Then onNLines
Print the outcomes. OnI-Th line print a space-separated pair of IntegersCI,DI-
The number of heads Vasya and Petya got inI-Th outcome of the game, correspondingly. Print pairs of Integers (CI, Bytes,DI) In
The strictly increasing order.
Let us remind you that the pair of numbers (P1, bytes,Q1) is
Less than the pair of numbers (P2, bytes,Q2 ),
IfP1 worker <workerP2,
OrP1 bytes = bytesP2 and
AlsoQ1 worker <workerQ2.
Sample test (s) Input
3 2 1 1
Output
32 13 13 2
Input
2 4 2 2
Output
0
Solution Description: brute force, dual loop, and judgment.
#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;}