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;
}
}

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

  1. Find Amir CodeForces - 805C (贪心+思维)

    A few years ago Sajjad left his school and register to another one due to security reasons. Now he w ...

  2. 【codeforces 805C】Find Amir

    [题目链接]:http://codeforces.com/contest/805/problem/C [题意] 你能从任意一个位置i到达任意一个位置j; 花费为(i+j)%(n+1); 问你从任意一个 ...

  3. CodeForces 805C Find Amir

    直觉. 先走$1$走到$n$,然后从$n$走到$2$,然后从$2$走到$n-1$,然后从$n-1$走到$3$.一次花费为$0$,一次花费为$1$. #include <cstdio> #i ...

  4. codeforces411div.2

    每日CF: 411div2 Solved A CodeForces 805A Fake NP Solved B CodeForces 805B 3-palindrome Solved C CodeFo ...

  5. codeforces 804A Find Amir 思维/水题

    A few years ago Sajjad left his school and register to another one due to security reasons. Now he w ...

  6. Codeforces Round #411 (Div. 2) C. Find Amir

    C. Find Amir time limit per test   1 second memory limit per test   256 megabytes   A few years ago ...

  7. 【推导】Codeforces Round #411 (Div. 1) A. Find Amir

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

  8. Codeforces Round #411 (Div. 2)(A,B,C,D 四水题)

    A. Fake NP time limit per test:1 second memory limit per test:256 megabytes input:standard input out ...

  9. codeforces——贪心

    codeforces 804A Find Amir   http://codeforces.com/problemset/problem/804/A /* 题意:给定n个学校,需要遍历所有学校,可从任 ...

随机推荐

  1. ubuntu上安装mysql的正确步骤

    1.在Ubuntu software Center中下载mysql:[注:mysql下载下来后好像就安装上了] 2.使用命令检查mysql是否已安装上: 2.1 运行sudo netstat -tap ...

  2. C# DataTable To Entities

    原地址忘了,修改过了一下. new: public static class DataTableEntityInteroperate { public static List<T> ToE ...

  3. 历届试题 买不到的数目-(dp)

    问题描述 小明开了一家糖果店.他别出心裁:把水果糖包成4颗一包和7颗一包的两种.糖果不能拆包卖. 小朋友来买糖的时候,他就用这两种包装来组合.当然有些糖果数目是无法组合出来的,比如要买 10 颗糖. ...

  4. Python基础学习Day3 数据类型的转换、int、str、bool、字符串的常用方法、for循环

    一.数据类型的转换 常用的是:int 转str.str转int.int转bool 时   非零即为 True . # 数据类型之间转换 ***** # int <--> str str(i ...

  5. Python str list to list

    eg1: My csv data like this below,i wt count list nums 2018上,"['C', 'B', 'B', 'B', 'D', 'A', 'B' ...

  6. .sh_history文件的管理机制

    来源:http://www.aixchina.net/Article/27258 字数 1056阅读 4365评论 1赞 0 内容提要: .sh_history是在ksh中用于存储用户在shell中输 ...

  7. vue 中安装使用sass 报错遇到的问题整理

    不出错的情况下,正常安装: 1.安装包: npm install node-sass --save-dev npm install sass-loader --save-dev (sass-loade ...

  8. CUDA 编程的基本模式

    reproduced from: http://www.cnblogs.com/muchen/p/6306747.html 前言 本文将介绍 CUDA 编程的基本模式,所有 CUDA 程序都基于此模式 ...

  9. Hudson 打包部署到Was上特别慢

    一.找问题点 1.打包很快,到部署很慢 2.部署到其他was一样很慢 二.解决 经过寻找,网上找出以下一段话: 问题出在web.xml,web.xml中的版本信息不对,要根据你的servlet版本和运 ...

  10. int 和 Integer 的区别

    1.两个New生成的Integer 永远不相等,因为他们的内存地址不相等 2.如果一个是New生成的Integer 另一个是通过赋值生成的话,如果值相等那么他们相等,因为这时Integer会通过自动拆 ...