codeforces-scrape

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

682A.md (1849B)


      1 Source: https://codeforces.com/problemset/problem/682/A
      2 
      3 A. Alyona and Numbers
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers from 1 to *m*. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.
     22 
     23 Formally, Alyona wants to count the number of pairs of integers (*x*, *y*) such that 1 ≤ *x* ≤ *n*, 1 ≤ *y* ≤ *m* and ![](https://espresso.codeforces.com/172ce45a535a02e9d636dcf4c462a2a1df6c3215.png) equals 0.
     24 
     25 As usual, Alyona has some troubles and asks you to help.
     26 
     27 Input
     28 
     29 The only line of the input contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 1 000 000).
     30 
     31 Output
     32 
     33 Print the only integer — the number of pairs of integers (*x*, *y*) such that 1 ≤ *x* ≤ *n*, 1 ≤ *y* ≤ *m* and (*x* + *y*) is divisible by 5.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 6 12
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 14
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 11 14
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 31
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 1 5
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 1
     71 ```
     72 
     73 Input
     74 
     75 ```
     76 3 8
     77 ```
     78 
     79 Output
     80 
     81 ```
     82 5
     83 ```
     84 
     85 Input
     86 
     87 ```
     88 5 7
     89 ```
     90 
     91 Output
     92 
     93 ```
     94 7
     95 ```
     96 
     97 Input
     98 
     99 ```
    100 21 21
    101 ```
    102 
    103 Output
    104 
    105 ```
    106 88
    107 ```
    108 
    109 Note
    110 
    111 Following pairs are suitable in the first sample case:
    112 
    113 * for *x* = 1 fits *y* equal to 4 or 9;
    114 * for *x* = 2 fits *y* equal to 3 or 8;
    115 * for *x* = 3 fits *y* equal to 2, 7 or 12;
    116 * for *x* = 4 fits *y* equal to 1, 6 or 11;
    117 * for *x* = 5 fits *y* equal to 5 or 10;
    118 * for *x* = 6 fits *y* equal to 4 or 9.
    119 
    120 Only the pair (1, 4) is suitable in the third sample case.