CodeForces 805C 思維

題意:有n個點,有一種從n點到m點的方式是花費(n+m)%(n+1)的代價;

           問:遍歷完所有n個點的最小花費

思路:每次都選擇mod(n+1)之後爲0 的一對數字

           第一次是第一個和最後一個數字

           第二次是最後一個數字和第二個數字

           。。。。。。

           1->n->2->n-1->3->...->

           我們花費的值是總數的一半減去1

           也就是(n-1)/2

代碼:

#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    scanf("%d",&n);
    printf("%d\n",(n-1)/2);
    return 0;
}

題目:

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.

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  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.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of schools.

Output

Print single integer: the minimum cost of tickets needed to visit all schools.

Examples

Input

2

Output

0

Input

10

Output

4

Note

In the first example we can buy a ticket between the schools that costs .

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章