Find Amir CodeForces 805C

时间:2023-03-08 18:07:53

http://codeforces.com/contest/805/problem/C

题意:有n个学校,学校的编号是从1到n,从学校i到学校j的花费是(i+j)%(n+1),让你求遍历完所有学校的最小花费

解析:你会发现头尾相加就会使得他等于n+1的,那么他的遍历顺序应该是

  1---->n------>2------>(n-1)------->3--------->(n-2)……      以此类推下去,就会发现最终的总花费就是(n-1)/2

花费   0          1          0               1             0

#include <iostream>
using namespace std; int main(){
int n;
while(cin >> n){
cout << (n - ) / << endl;
}
}