codeforces-scrape

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

678B.md (1177B)


      1 Source: https://codeforces.com/problemset/problem/678/B
      2 
      3 B. The Same Calendar
      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 The girl Taylor has a beautiful calendar for the year *y*. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
     22 
     23 The calendar is so beautiful that she wants to know what is the next year after *y* when the calendar will be exactly the same. Help Taylor to find that year.
     24 
     25 Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (<https://en.wikipedia.org/wiki/Leap_year>).
     26 
     27 Input
     28 
     29 The only line contains integer *y* (1000 ≤ *y* < 100'000) — the year of the calendar.
     30 
     31 Output
     32 
     33 Print the only integer *y*' — the next year after *y* when the calendar will be the same. Note that you should find the first year after *y* with the same calendar.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 2016
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 2044
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 2000
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 2028
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 50501
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 50507
     71 ```
     72 
     73 Note
     74 
     75 Today is Monday, the 13th of June, 2016.