[Codeforces805] C. Find Amir

xiaoxiao2021-02-28  95

题目链接:http://codeforces.com/contest/805/problem/C

思路: 头尾相加就等于n+1,花费最少的遍历顺序就是1->n->2->(n-1)->3->(n-2)…… 可以发现结果就是 (n-1)/2

#include <iostream> #include <cstdio> using namespace std; int main() { int n; scanf("%d",&n); int ans=(n-1)/2; printf("%d\n",ans); return 0; }
转载请注明原文地址: https://www.6miu.com/read-80289.html

最新回复(0)