codeforces-scrape

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

659A.md (1726B)


      1 Source: https://codeforces.com/problemset/problem/659/A
      2 
      3 A. Round House
      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 Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
     22 
     23 Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he decided that during his walk he will move around the house *b* entrances in the direction of increasing numbers (in this order entrance *n* should be followed by entrance 1). The negative value of *b* corresponds to moving |*b*| entrances in the order of decreasing numbers (in this order entrance 1 is followed by entrance *n*). If *b* = 0, then Vasya prefers to walk beside his entrance.
     24 
     25  ![](https://espresso.codeforces.com/9fcaffa32cbd86f4e151dbe8918d2c3feca51efb.png) Illustration for *n* = 6, *a* = 2, *b* =  - 5. 
     26 
     27 Help Vasya to determine the number of the entrance, near which he will be at the end of his walk.
     28 
     29 Input
     30 
     31 The single line of the input contains three space-separated integers *n*, *a* and *b* (1 ≤ *n* ≤ 100, 1 ≤ *a* ≤ *n*,  - 100 ≤ *b* ≤ 100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively.
     32 
     33 Output
     34 
     35 Print a single integer *k* (1 ≤ *k* ≤ *n*) — the number of the entrance where Vasya will be at the end of his walk.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 6 2 -5
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 3
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 5 1 3
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 4
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 3 2 7
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 3
     73 ```
     74 
     75 Note
     76 
     77 The first example is illustrated by the picture in the statements.