CodeForces 805C Find Amir】的更多相关文章

直觉. 先走$1$走到$n$,然后从$n$走到$2$,然后从$2$走到$n-1$,然后从$n-1$走到$3$.一次花费为$0$,一次花费为$1$. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> using namespace std; int n; int main() { scanf("%d"…
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 d…
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         …
[题目链接]:http://codeforces.com/contest/805/problem/C [题意] 你能从任意一个位置i到达任意一个位置j; 花费为(i+j)%(n+1); 问你从任意一个位置,直到走过所有的位置的最小花费; [题解] 找规律; 会发现 如果n为奇数 答案是(n-1)/2; 如果是偶数 答案是(n-2)/2; [Number Of WA] 0 [完整代码] #include <bits/stdc++.h> using namespace std; #define l…
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 d…
每日CF: 411div2 Solved A CodeForces 805A Fake NP Solved B CodeForces 805B 3-palindrome Solved C CodeForces 805C Find Amir Solved D CodeForces 805D Minimum number of steps Attempted E CodeForces 805E Ice cream coloring     F CodeForces 805F Expected dia…
codeforces 804A Find Amir   http://codeforces.com/problemset/problem/804/A /* 题意:给定n个学校,需要遍历所有学校,可从任意一点开始. i到j有(i+j) mod (n+1) 的花费,求最小花费. 考虑贪心:先走和为n+1的两处,走完后最小只能再走到和为n+1的学校,再走到和为n的 例如: 1 2 3 4 5 6 7 8 9 10 先走1->10 花费为0 再走10->2 花费为1 再走2->9 花费为0 ..…
C. Find Amir time limit per test   1 second memory limit per test   256 megabytes   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…
1 2 3 4 5 6 7 4-5-3-6-2-7-1 答案是(n-1)/2 #include<cstdio> using namespace std; int n; int main(){ scanf("%d",&n); printf("%d\n",(n-1)/2); return 0; }…
A. Fake NP time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.…