A. Trip For Meal time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbi…
http://codeforces.com/contest/876/problem/D 题意:题意真是难懂,就是给一串序列,第i次操作会在p[x](1<=x<=i)这些位置放上硬币,然后从左到右观察,如果第i个位置有硬币但第i+1个位置没有硬币,那么互换,然后继续从第i+1个硬币开始看.直到不需要交换,需要计算出到终极状态需要多少步. 思路: 模拟. #include<iostream> #include<algorithm> #include<cstring&g…
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去相邻点,要走过n个点,求走过的最短距离. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n, a, b, c; scanf("…
Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的最短路径. solution 当\(n=1\)时,答案为\(0\),当\(n=2\)时,答案等于与开始点相连的两条边的最小值,当\(n>2\)时,答案等于与开始点相连的两条边的最小值+三条边最小值*\((n-2)\) 时间复杂度:\(O(1)\) B. Divisiblity of Differen…
上次打了一发 Round #440 Div.2 结果被垃圾交互器卡掉 $200$ Rating后心情复杂... 然后立了个 Round #441 要翻上蓝的flag QAQ 晚饭回来就开始搞事情, 大力安利了一发 Codeforces 然后成功拉到隔壁机房 $N$ 个 dalao 一起开黑 (垃圾 Codeforces 的 CAPTCHA 居然还要架梯子才能用...) 顺便备好 TIM 准备连线 UOJ 群 233 (算了不扯赛前了直接说赛中...) 开场开 $A$ 题, 一脸懵逼? (论 CF…
A. Trip For Meal 题目链接:http://codeforces.com/contest/876/problem/A 题目意思:现在三个点1,2,3,1-2的路程是a,1-3的路程是b,2-3的路程是c,从1点开始,小熊维尼在1点吃过一次蜂蜜了,但是他要吃n次蜂蜜,每次他离开一个地方以后这个地方的蜂蜜就会自动补充,问最少需要走多少距离. 题目思路:如果n=1,那么就是0,如果n等于2,那么答案说就是min(a,b),如果n>2,答案就是min(a,b)+(n-2)*min(a,b,…
题目链接 A. Trip for Meal 题意 三个点之间两两有路径,分别长为\(a,b,c\),现在从第一个点出发,走\(n-1\)条边,问总路径最小值. 思路 记起始点相邻的边为\(a,b\),相对的边为\(c\). 首先肯定走\(a,b\)中的最小值(不妨设为\(a\)),到达另一个顶点.那么这个顶点所连的两条边\(a,c\)中必然有一个是\(a,b,c\)三者中的最小值,否则最小值就为\(b\),与初始的选择矛盾. 于是接下来只需要在最小值的路上反复走即可. Code #include…
A. Trip For Meal Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses.…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake…
http://codeforces.com/contest/876/problem/A 题意: 一个人一天要吃n次蜂蜜,他有3个朋友,他第一次总是在一个固定的朋友家吃蜂蜜,如果说没有吃到n次,那么他就继续去另外的朋友家. 当他在一个朋友家吃的时候,另外的朋友家的蜂蜜就会恢复供应. 问这个人走的最小的距离. 一开始因为审题不清楚,忽略了第一次是固定的,所以wa了. 代码: #include <stdio.h> #include <algorithm> using namespace…
http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的"O"变为"X",之后会进行扫描. 扫描的规则是如果遇到一个字符为"X"并且这个字符后面的字符为"O",那么就交换. 如果哪一次扫描没有发生交换,那么扫描就停止. 现在给出的n个数字,问第一次需要扫描多少次,第二次需要扫描多少次....…
http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: n最大1e9,那么9个9最多才加81,所以最多枚举100次,就可以找到所有符合条件的数. 代码: #include <stdio.h> #include <string.h> #include <vector> using namespace std; vector<…
http://codeforces.com/contest/876/problem/B 题意: 给出n个数,要求从里面选出k个数使得这k个数中任意两个的差能够被m整除,若不能则输出no. 思路: 差能够被m整除,其实就是对m取余的余数相同.那么就统计n个数的余数丢到一个map里面,最后判断是否有某个数的数量大于等于k. 代码: #include <stdio.h> #include <map> #include <vector> using namespace std;…
F - High Cry 题目大意:给你n个数,让你找区间里面所有数或 起来大于区间里面最大数的区间个数. 思路:反向思维,找出不符合的区间然后用总数减去.我们找出每个数掌控的最左端 和最右端,一个数的掌控区域为,这个区域里的或 为本身. 注意两个相同的数有可能掌控区域一样,记得将区域分段. #include<bits/stdc++.h> #define ll long long using namespace std; *1e5+; int n,a[N],l[N],r[N]; map<…
A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. Th…
A:显然答案与原数的差不会很大. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long char getc(){char c=getchar();while ((c<'A'||c>…
E. National Property time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in…
F. High Cry time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Disclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you t…
比赛的时候E调了好久...F没时间写T T A:直接走到短的路上来回走就好了 #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ,inf=1e9; int n,a,b,c; inline void read(int &k)…
C. time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n.…
Discription Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is th…
http://codeforces.com/contest/435/problem/C…
Thor 题意: 第一行n和q,n表示某手机有n个app,q表示下面有q个操作. 操作类型1:app x增加一条未读信息. 操作类型2:一次把app x的未读信息全部读完. 操作类型3:按照操作类型1添加的顺序,按顺序读t条信息,注意这t条信息可能有的已经读过.如果读过也算前t条,会再读一遍. 最后输出每次操作有多少信息没读. 题解: 一看题,要30W,那肯定不可以n^2了,想一想,3种操作,一个vector够用吗,应该不够,所以再加个set,就差不多了.那么思路就是这样的: 首先要有个计数器c…
A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us. The gi…
题意:给出n个电视节目的起始和结束时间  并且租一台电视需要x +y*(b-a)  [a,b]为时段 问完整看完电视节目的最小花费是多少 思路:贪心的思想 情况1 如果新租一台电视的花费<=在空闲电视上面看节目 那么肯定新租电视 情况2 否则就直接在空闲电视上看 就好 模拟难(QAQ): 这里使用多重集合模拟   先把所有时间的pair(结束时间,开始时间) 放入多重集里面 然后开一个数组以l 从小到大排序 从数组小到大 枚举  在多重集里面找离终点最近的那个点 如果符合情况1 那么就删去 找到…
C. Zebras time limit per test memory limit per test 512 megabytes input standard input output standard output Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a …
C. Heap Operations 题目连接: http://www.codeforces.com/contest/681/problem/C Description Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following operations: put the given number into the…
D. Tree Construction 题目连接: http://www.codeforces.com/contest/675/problem/D Description During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so…