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. 3DMAX 批量 场景 对象 导出 .X格式 脚本

    一.首先你需要下载一个 Total Commader文件管理软件.利用这个软件你可以收集文件夹下包含子文件夹下的max文件(或完整路径)打开TotalCMD后使用查找文件:(如图红框中的操作)1. 2 ...

  2. 吴裕雄 python 机器学习-KNN(2)

    import matplotlib import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import ...

  3. 学JS的心路历程-函式(四)apply、call

    从上一篇可以知道,不同的函式呼叫会造成this的不同,但我们能不能在呼叫时候明确指定呢? 当然可以.会有这个想法是因为往往在执行某支函式时想要用回呼函式(mizumisushi),但发现this总是显 ...

  4. java中excel导入\导出工具类

    1.导入工具 package com.linrain.jcs.test; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import ...

  5. Spring 手动 提交事务

    1.配置文件 applicationContext.xml: <bean id="txManager"class="org.springframework.jdbc ...

  6. NPM安装依赖速度慢问题

    [NPM安装依赖速度慢问题] npm config set registry http://registry.npm.taobao.org 参考:http://blog.csdn.net/rongbo ...

  7. java和c#中String

    java中: c#中: 1.拼接字符串 sql语句中 in() str="'001','002','003'";至于产生string就这样  str1="'001'&qu ...

  8. 重工单001800020505在IN表IN_SFCHEADER被过滤 TEMP_REMOVED_ID_IN_DATA

    select * from SAP_AFKO WHERE AUFNR='001800020505';  ---有数据SELECT * FROM IN_SFCHEADER WHERE MO_ID ='0 ...

  9. android 常用渐变背景绘制

    从上到下绘制如图所示 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android= ...

  10. 大数据hadoop的伪分布式搭建

    1.配置环境变量JDK配置 1.JDK安装 个人喜欢在 vi ~/.bash profile   下配置 export JAVA_HOME=/home/hadoop/app/jdk1.8.0_91ex ...