[ABC347C] Ideal Holidays题解】的更多相关文章

Content 假设 \(1\) 年有 \(n\) 天,而每周同样会有 \(5\) 天工作日和 \(2\) 天休假.求一年最小的休假天数和最大休假天数. 数据范围:\(1\leqslant n\leqslant 10^6\). Solution 题解区的做法都稍麻烦了些,其实这道题目只需要两行代码就能够搞定.一行输入,一行输出结果. 没听错,一行直接输出答案.原因是这道题目其实是有公式的. 首先我们知道,一年里面有 \(\left\lfloor\dfrac n7\right\rfloor\) 个…
D. Holidays Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/D Description Everyone knows that the battle of Endor is just a myth fabled by George Lucas for promotion of his movie. Actually, no battle of Endor has…
Fence Rails题解 Burch, Kolstad, and Schrijvers Farmer John is trying to erect a fence around part of his field. He has decided on the shape of the fence and has even already installed the posts, but he's having a problem with the rails. The local lumbe…
A. Holidays 题目连接: http://www.codeforces.com/contest/670/problem/A Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings - 5 work days and then 2 days off. Your tas…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 逆向做一遍bfs. 得到终点到某个点的最短距离. 这样,我们从起点顺序的时候. 就能知道最短路的下一步是要走哪里了. 这样,我们从起点也开始做一遍bfs. 然后根据逆序的bfs得知下一步该往哪些点走. 每次优先走最小的字典序边即可. 多个最小的,就每个都走一遍试试. 6 6 1 2 3 1 3 3 2 4 5 3 5 1 4 6 1 5 6 100 ans = 3->1->100 ↑↑这组数据可以hack网上好多人(>=…
简介 虚树,即剔除所有无关结点,只保留询问点和询问点的相关结点(两两之间的LCA),建一棵新树,这棵新树就是虚树.通过虚树,可以有效的减小询问(甚至修改)的复杂度.设询问点的个数是\(k\),那么建虚树的一般方法的时间复杂度为\(O(k \log k)\). 构建方法 把所有询问点按dfs序排个序. 求出所有相邻结点的LCA(相关点)加入数组,结束后把根结点(\(1\))也加入数组. 再把所有询问点和相关点按dfs序排个序. 用栈维护虚树上根结点出发的一条链,按dfs序逐个插入结点,弹栈时连虚树…
A. Fair Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Befor…
Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroom and turned…
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我没看,看不懂. 基本思路:我不会. 参考代码:找Oyk老师和Czj老师去. B. The background of water problem 题目大意(大写加粗的水题):给定$N$个学生和他们$K$个科目的成绩$S_i$,再给出各科目$K_i$的权重顺序$Q_i$,求排名之后,拥有id为$X$的…
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <…