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个学校,需要遍历所有学校,可从任 ...
随机推荐
- SQL Server GROUP BY 后 拼接 字符串
原文地址:https://blog.csdn.net/u010673842/article/details/79637618 select ID, ,,'') from class a group b ...
- 吴裕雄 python深度学习与实践(1)
#coding = utf8 import threading,time count = 0 class MyThread(threading.Thread): def __init__(self,t ...
- “2017面向对象程序设计(Java)第十一周学习总结”存在问题的反馈及教学安排
“2017面向对象程序设计(Java)第十一周学习总结”存在问题的反馈及教学安排1.“提出表扬的同学:姜依萍,王雪玲,徐楠,相文君,赵晓未提交作业的同学:任红强,王瑞强,宗鹏新,扎西才让,布旦刀杰,范 ...
- Linux下开启计划任务日志
crontab记录日志 修改rsyslog vim /etc/rsyslog.d/50-default.conf (我的是root用户) 搜索cron 把如下行之前的注释"#"去掉 ...
- 在Laravel外独立使用laravel-mongodb
laravel框架外部使用laravel-mongodb 插件 下载安装方式主要根据github上的参考: https://github.com/jenssegers/laravel-mongodb# ...
- ES5新增数组方法every()、some()、filter()、map()
JavaScript ES5标准中新增了一些Array方法,如every().some().filter().map().它们的出现使我们能够更加便利地操作数组,但对IE9以下浏览器的兼容性比较差.下 ...
- CSS中的通用字体
往往设计师在设计时一厢情愿地去思考问题,那样会带来很多潜在的麻烦.事实上你可以为网页设计任意字体,包括艺术字体.也许你的计算机中已经安装了很多字体,但是不能够保证所有的浏览者都已经安装了相同的字体,因 ...
- 学习笔记001之[Android开发视频教学].01_06_Android当中的常见控件
文本框,按钮 菜单按钮(需复写两个方法) 后续需完成联系代码.
- C#实现将字符串作为表达式运算
转载:http://blog.csdn.net/lifeforcode/article/details/2010807 曾经有个需求,要把一段字符串作为C#的一段语句来执行.说实在了,就类似实现计算器 ...
- python对ftp进行操作
背景:需要对ftp进行操作,涉及上传和下载操作 from ftplib import FTP ftp = FTP(host=“ftp的hostname",user=‘登录用户名', pa ...