codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

242A.md (1900B)


      1 Source: https://codeforces.com/problemset/problem/242/A
      2 
      3 A. Heads or Tails
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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.
     24 
     25 Input
     26 
     27 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.
     28 
     29 Output
     30 
     31 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 *c**i*, *d**i* — the number of heads Vasya and Petya got in the *i*-th outcome of the game, correspondingly. Print pairs of integers (*c**i*, *d**i*) in the strictly increasing order.
     32 
     33 Let us remind you that the pair of numbers (*p*1, *q*1) is less than the pair of numbers (*p*2, *q*2), if *p*1 < *p*2, or *p*1 = *p*2 and also *q*1 < *q*2.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 3 2 1 1
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 3  
     47 2 1  
     48 3 1  
     49 3 2
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 2 4 2 2
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 0
     62 ```