codeforces-scrape

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

804A.md (1204B)


      1 Source: https://codeforces.com/problemset/problem/804/A
      2 
      3 A. Find Amir
      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 A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
     22 
     23 There are *n* schools numerated from 1 to *n*. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools *i* and *j* costs ![](https://espresso.codeforces.com/48a4e5770c4d95918ab20e59965b1361f52acc70.png) and can be used multiple times. Help Sajjad to find the minimum cost he needs to pay for tickets to visit all schools. He can start and finish in any school.
     24 
     25 Input
     26 
     27 The first line contains a single integer *n* (1 ≤ *n* ≤ 105) — the number of schools.
     28 
     29 Output
     30 
     31 Print single integer: the minimum cost of tickets needed to visit all schools.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 2
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 0
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 10
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 4
     57 ```
     58 
     59 Note
     60 
     61 In the first example we can buy a ticket between the schools that costs ![](https://espresso.codeforces.com/c67d72010e0498bfd065a6a38fdeaec90358507b.png).