Codeforces 702 D Road to Post Office】的更多相关文章

题目描述 Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to ddkilometers. Vasiliy's car is not new — it breaks after driven every kk kilometers and Vasiliy needs tt seconds to repair it. Afte…
Road to Post Office 题意: 一个人要从0走到d,可以坐车走k米,之后车就会坏,你可以修或不修,修要花t时间,坐车单位距离花费a时间,走路单位距离花费b时间,问到d的最短时间. 题解: 首先要分成k段,k段的总长是ovmod,每一段可以选择修车坐车或选择走路,(只有第一段的时候不用修车),最后在加上剩下的那些路的时间,剩下的是mod,(可以选择修车坐车或选择走路)最后min答案就好了.但其中还有一种情况要注意,就是前ovmod也可以选择坐车之后不修走着,所以这种要特殊处理下.…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
题目链接: D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals t…
Codeforce 702 D. Road to Post Office 解析(思維) 今天我們來看看CF702D 題目連結 題目 略,請直接看原題. 前言 原本想說會不會也是要列式子解或者二分搜,沒想到意外的是思考非常簡單的一題 @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 如果坐車\(k\)公里加上修理比走路\(k\)公里還要慢,那麼我們只需要先坐車\(k\)公里,然後不要修,直接走路走完全程. 如果坐車\(k\)公里加上…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
题目链接:http://codeforces.com/problemset/problem/702/D 题意: 一个人要去邮局取东西,从家到达邮局的距离为 d, 它可以选择步行或者开车,车每走 k 公里就要花费 t秒修一次才可以继续开,车每公里花费 a秒,步行每公里花费 b秒.依次给出d, k, a, b, t.问最少需要花费多少时间到达邮局.车刚开始时是好的. 思路: 首先可以模拟一下,可以想到,如果车速比步速块,那么前 k公里路肯定选择坐车,因为开始时车是好的,不用花费多余的时间来修理车,否…
答案的来源不外乎于3种情况: 纯粹走路,用时记为${t_1}$:纯粹乘车,用时记为${t_2}$:乘车一定距离,然后走路,用时记为${t_3}$. 但是${t_1}$显然不可能成为最优解. 前两个时间都挺好算的,${t_3}$算的时候要讨论一下. 如果是$a*k+t>=b*k$,那么也就是说第一个$k$的距离开车,然后开始走路. 如果是$a*k+t<b*k$,那么可以尝试着最后不到$k$的距离走路,前面的都开车. 直接得出数学公式有点难度,因为最优解不会逃出${t_1}$,${t_2}$,${…
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…
http://codeforces.com/contest/702 题意:人到邮局去,距离d,汽车在出故障前能跑k,汽车1公里耗时a,人每公里耗时b,修理汽车时间t,问到达终点最短时间 思路:计算车和人的平均速度,谁快用谁,最后特判<=k的距离 // #pragma comment(linker, "/STACK:102c000000,102c000000") #include <iostream> #include <cstdio> #include &…
题目:http://codeforces.com/problemset/problem/543/D 题意:给你一棵树,一开始边都是0,可以使任意的边变成1,对于每一个根节点求使得它到其他任一点的路径上只有一条0边的方案数. 假设只求一个根,f[u]=∏(s[v]+1) 然后移动根节点这样就可以通过遍历一遍树得到所有点的答案了. s[v]=(s[u]/(s[v]+1)+1)*s[v] 这样当前根和根的其他子树就变成v的子树了(前面那坨就是它的贡献.. (看起来是这样没错..但是不能求逆元.因为s[…
A. Ring road time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The g…
Berland has n cities, some of them are connected by bidirectional roads. For each road we know whether it is asphalted or not. The King of Berland Valera II wants to asphalt all roads of Berland, for that he gathered a group of workers. Every day Val…
题意:给定 n 个数,问你连续的最长的序列是几个. 析:从头扫一遍即可. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorith…
    题意             n个数1~n按顺序围成一个圈...现在在某些两点间加边..边可以加在圈内或者圈外..问是否会发生冲突?如果不发生冲突..输每一条边是放圈内还是圈外.     题解             这道题和POJ 3207差不多了..只是那道题只要判断是否存在不要输出方案...发现个很严重的问题..POJ 3207的数据实在是太弱了..我上一个程序里判断两个线段是否相交是个错了..都让我AC了..导致我做这题是沿用了思路...浪费了很多时间...          …
比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <vector> #include &…
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d ki…
A题Maximum Increase 大水题.最长连续递增子序列有多长. #include <cstdio> #include <algorithm> using namespace std; int main() { , len = , ans = ; scanf("%d",&n); ; i < n; i++) { scanf("%d", &a); if(a > rec) { rec = a, len++; }…
I collect and make up this pseudocode from the book: <<Introduction to the Design and Analysis of Algorithms_Second Edition>> _ Anany LevitinNote that throughout the paper, we assume that inputs to algorithms fall within their specified ranges…
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数(n<=200). 首先很明显可能是区间dp,我们可以记f[i][j]为从i到j的这个多边形的三角剖分数,那么f[i][j]=f[i][k]*f[j][k]*(i,j,k是否为1个合格的三角形) Code: #include<cstdio> #include<iostream> #…
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停下来,竖直走. // 问走到终点的最短时间 // 思路: // 1.贪心来做 // 2.我觉的二分更直观 // 可以抽象成:一条射线与凸边行相交,判断交点.二分找切点 #include <bits/stdc++.h> using namespace std; #define LL long lon…
B. President's Office 题目连接: http://codeforces.com/contest/6/problem/B Description President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a un…
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…
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…
Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做,其实真的应该认真想想的,一般cf前3题仔细想想是可以出的,其实思路很简单,如下: 题解:一共有三种情况: ①. 人以最大速度u前进时,汽车的速度很慢,任意一点都到达不了人的位置 ②.人以最大速度u前行时,汽车的速度很快,在人达到之前汽车的任意一点都已经通过了y轴 ③.人以最大速度u前进时,会与汽车…
题目链接: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…
D - Toll RoadTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87493#problem/D Description Exactly N years ago, a new highway between two major cities was built. The highway runs from west to east. It…