Find Amir CodeForces 805C
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的更多相关文章
- Find Amir CodeForces - 805C (贪心+思维)
A few years ago Sajjad left his school and register to another one due to security reasons. Now he w ...
- 【codeforces 805C】Find Amir
[题目链接]:http://codeforces.com/contest/805/problem/C [题意] 你能从任意一个位置i到达任意一个位置j; 花费为(i+j)%(n+1); 问你从任意一个 ...
- CodeForces 805C Find Amir
直觉. 先走$1$走到$n$,然后从$n$走到$2$,然后从$2$走到$n-1$,然后从$n-1$走到$3$.一次花费为$0$,一次花费为$1$. #include <cstdio> #i ...
- codeforces411div.2
每日CF: 411div2 Solved A CodeForces 805A Fake NP Solved B CodeForces 805B 3-palindrome Solved C CodeFo ...
- codeforces 804A Find Amir 思维/水题
A few years ago Sajjad left his school and register to another one due to security reasons. Now he w ...
- 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 ...
- 【推导】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() ...
- 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 ...
- codeforces——贪心
codeforces 804A Find Amir http://codeforces.com/problemset/problem/804/A /* 题意:给定n个学校,需要遍历所有学校,可从任 ...
随机推荐
- tf.name_scope()和tf.variable_scope() (转)
网络层中变量存在两个问题: 随着层数的增多,导致变量名的增多: 在调用函数的时候,会重复生成变量,但他们存储的都是一样的变量. tf.variable不能解决这个问题. 变量作用域使用tf.var ...
- Mac中使用pycharm引包matplotlib失败
最开始是使用matplotlib这个包,然后在pycharm中失败,然后在终端中pip install matplotlib,发现,安装了以后,pycharm依然找不到包. 代码如下: import ...
- 历届试题 小数第n位-(同余公式+快速幂)
问题描述 我们知道,整数做除法时,有时得到有限小数,有时得到无限循环小数. 如果我们把有限小数的末尾加上无限多个0,它们就有了统一的形式. 本题的任务是:在上面的约定下,求整数除法小数点后的第n位开始 ...
- 微信小程序----搜索框input回车搜索事件
在微信小程序里的搜索框,按软键盘回车键触发搜索事件. <input type="text" placeholder="搜索" value="{ ...
- cmd从新获取ip
1.ipconfig/release 2.ipconfig/renew
- springboot-day01-引入如何读取配置文件以及helloWorld
前言:该文章是紧接上一篇文章http://www.cnblogs.com/newAndHui/p/8058527.html 3.3. 实战 3.3.1.读取外部的资源配置文件 通过@PropertyS ...
- 区分action, service和dao
在这里,我们不仅要处理页面逻辑,还要做业务逻辑,还要做数据访问.比如说: public String addUser() { if(user == null) { return FAIL_NO_USE ...
- DataGridView中DataGridViewComboBoxColumn的一些相关应用(一)让其值改变时触发事件-转
转自 https://maodaili.de/mao.php?u=a%2FMrbEvUE8PnCuc7FrhJi0Rqd3kmOBHPZUbcJ1c2hbJUK0RYWpAf4lhIOddItP%2 ...
- leetcode 树类型题
树的测试框架: // leetcodeTree.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream& ...
- 二进制中1的个数(python)
题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. # -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): ...