CodeForces 738C Road to Cinema】的更多相关文章

二分答案. 油量越多,显然通过的时间越少.可以二分找到最小的油量,可以在$t$时间内到达电影院. 一个油箱容量为$v$的车通过长度为$L$的路程需要的最小时间为$max(L,3*L-v)$.计算过程如下: 假设普通速度运行了距离$a$,加速运行了距离$b$,则$a+b=L$,即$b=L-a$. 因为$a+2*b≤v$,所以$a≥2*L-v$.所花时间为$2*a+b≥3*L-v$,因为最小需要$L$的时间,所以取个$max$.按照$max(L,3*L-v)$一段一段加起来验证就可以了. #prag…
题目链接 http://codeforces.com/problemset/problem/729/C 题意:n个价格c[i],油量v[i]的汽车,求最便宜的一辆使得能在t时间内到达s,路途中有k个位置在g[i]的加油站,可以免费加满油,且不耗时间.每辆车有两种运行模式可以随时切换:1.每米一分钟两升油:2.每米两分钟一升油. 看到10^5次加上循环两次就想到二分或者线段树或者看错题意了. 这题二分查找一下汽油就可以了,找到最少多少汽油够到达,然后再for一遍找汽油量大的且价格便宜的车即可. 还…
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t m…
C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t m…
题目链接:http://codeforces.com/problemset/problem/729/C C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinem…
Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minu…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a str…
题目链接:http://codeforces.com/contest/543/problem/D 给你一棵树,初始所有的边都是坏的,要你修复若干边.指定一个root,所有的点到root最多只有一个坏边.以每个点为root,问分别有多少种方案数. dp[i]表示以i为子树的root的情况数,不考虑父节点,考虑子节点.   dp[i] = dp[i] * (dp[i->son] + 1) up[i]表示以i为子树的root的情况数(倒着的),考虑父节点,不考虑子节点.  这里需要逆元. 注意(a/b…
http://codeforces.com/contest/543/problem/D 题意: 给定n个点的树 问: 一开始全是黑边,对于以i为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑边,输出染色的方案数(mod 1e9+7) 思路:得知f[x]=(f[s1]+1)*(f[s2]+1)*(f[s3]+1)..*(f[sn]+1),s为x的儿子 因为要么这条边修了,里面有f[s1]方案,要吗不修,那剩下的都必须修. 由于要计算每个点的答案. 我们令up[x]为x父亲为x儿子时的f答…