codeforces 722E Research Rover】的更多相关文章

codeforces 722E Research Rover 题意 \(1e5*1e5\)的棋盘中有\(2000\)个坏点,初始给定一个值\(s(1<=s<=1e6)\).从棋盘左上角走到右下角,只允许向右或者向下走,每经过一个坏点,\(s=\lceil{s/2}\rceil\),求到达棋盘右下角时,\(s\)的值的期望. 题解 经过\(log\)级别的坏点之后,\(s\)的值就衡为\(1\)了.对所有坏点根据\(x\)从小到大,\(y\)从小到大排序. \(f_{i, j}\)表示从坏点\(…
Research Rover Time Limit: 25 Sec  Memory Limit: 256 MB Description Input Output 仅一行一个整数表示答案. Sample Input 3 3 2 11 2 1 2 3 Sample Output 333333342 HINT Main idea 从(1,1)走到(n,m),每次可以向右或向下走一步,有K个特殊点,初始有一个权S,每经过一个特殊点S=(S+1)/2,询问到(n,m)的S的期望. Solution 我们显…
[Codeforces722E] Research Rover (dp+组合数学) 题面 给出一个N*M的方格阵,从(1,1)出发,到(N,M)结束,从(x,y)只能走到(x+1,y)或(x,y+1).方格阵上还有K个特殊点,初始时给出的分数t每经过一个特殊点就会变成\([\frac{t}{2}]\).求到(N,M)时得分的期望.保证(1,1)和(N,M)不是特殊点.\(N,M≤100000,\ K≤2000,\ t≤1000000\) 分析 考虑根据特殊点dp.把(1,1)和(n,m)也看作特…
题目大意:对于一个不完全二分图,根节点为1,叶节点值为0或1,非叶节点包含一个操作(and,or,xor,not),求改变各个叶节点的值时(即0改为1,1改为0),根节点的值是多少 解法:遍历图求各节点的值,改变每个叶节点时,向图根节点遍历,求根节点值即可 有两个需要剪枝的地方,一,当改变到当前节点是该节点值已经不在改变,则结束图的向上递归 二,维护每个节点改变时,根节点的值,当再次遍历次节点时,可直接得到答案,结束递归 #include<iostream> #include<cstdi…
题意:有一个n * m的棋盘,你初始在点(1, 1),你需要去点(n, m).你初始有s分,在这个棋盘上有k个点,经过一次这个点分数就会变为s / 2(向上取整),问从起点到终点的分数的数学期望是多少? 思路:按照套路,先把这k个点按照pair的方式进行排序,设dp[i][j]为从起点到点i之前经过了至少j个减分点,到点i的数学期望.那么所有在它之前的可以向它转移的点向它转移.那么dp[i][j] = Σ(dp[u][j - 1] - dp[u][j]) * g(u, i).其中g(u, i)是…
CF722E Research Rover Unfortunately, the formal description of the task turned out to be too long, so here is the legend. Research rover finally reached the surface of Mars and is ready to complete its mission. Unfortunately, due to the mistake in th…
[链接]h在这里写链接 [题意] 在这里写题意 [题解] t<=k,输出t t>=n,输出k-t+n 其他情况都是k [错的次数] 0 [反思] 在这了写反思 [代码] /* */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <map> #include &l…
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100002 Description In the near future any research and publications about cryptography are outlawed throughout the world on the grounds of national se…
Codeforces Round #432 (Div. 2, based on IndiaHacks Final Round 2017)  A. Arpa and a research in Mexican wave time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Arpa is researching the Mexican…
C. NP-Hard Problem time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very int…
C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting. Suppose the graph G is given. Subs…
B. Kay and Snowflake 题目连接: http://www.codeforces.com/contest/685/problem/B Description After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes. Once upon a time,…
B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mat…
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B.Rocket 极其简单的一道交互题,有些位置会说反的,那么就选一个数来询问直接选出所有的这样的位置 显然,选择\(\rm 1\)和\(\rm m\)都可以,选择完之后直接二分就行了 代码: #include<cstdio> #include<iostream> #include<…
题目链接:http://codeforces.com/contest/340/problem/E E. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's sta…
Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm specialist....\) A. Fly 二分答案,送分题. #include<bits/stdc++.h> using namespace std; void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch…
https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have n tickets to sell. The price of the i-th ticket is pi.…
链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have n tickets to sell. The price of the i-th ticket…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
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/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连通图)且这颗树中必须包含节点1 然后将这颗子树中的所有点的点权+1或-1 求把所有点权全部变为0的最小次数(n<=10^5) 题解: 因为每一次的子树中都必须有1,所以我们得知每一次变换的话1的权值都会变化 所以我们以1为根 现在,我们发现,如果一个节点的权值发生变化,那么他的父节点的权值一定发生变…
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a3-+ai,问满足Si<=p的i的最大值的期望.(p<=50) (大意来自于http://www.cnblogs.com/liu-runda/p/6253569.html) 我们知道,全排列其实等价于我们一个一个地等概率地向一个序列里面插入数值 所以我们可以这么看这道题: 现在有n个数,有n个盒子…
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不同的点的数量+1) 每一次只有当子树中所有的点都已经游走过了再会向父亲走,走到每个儿子上的概率是相同的 对于每个点,求他的权的期望 (1 ≤ n ≤ 10^5) 题解: 首先我们发现,所有子树中所有的点的编号都一定比父亲要大 而且子树中的大小关系和我们访问它的顺序有关 如果对于一个节点u它的儿子为v…
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次抓一只老鼠,龙每次抓完一只老鼠之后会有一只老鼠跑出来. 每次抓老鼠和跑出来的老鼠都是随机的. 如果两个人都没有抓到白色老鼠则龙赢.王妃先抓. 问王妃赢的概率. (0 ≤ w, b ≤ 1000). 题解: 其中第一行表示为王妃拿到的白色老鼠,自然是直接退出了 第二行表示为王妃拿到了黑色老鼠,但是因为…
http://codeforces.com/problemset/problem/453/A 题目大意: 给定一个m面的筛子,求掷n次后,得到的最大的点数的期望 题解 设f[i]表示掷出 <= i 的点数的概率 ans = sigma{i*(f[i]-f[i-1])} 单个f[i]直接快速幂计算 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typede…
http://codeforces.com/problemset/problem/749/E (题目链接) 题意 给出一个1~n的排列,从中等概率的选取一个连续段,设其长度为l.对连续段重新进行等概率的全排列,求排列后整个原序列的逆序对的期望个数. Solution 考虑对于每一对数${(a_i,a_j),i<j}$算贡献. 1.连续段包含${a_i,a_j}$ 不妨设${a_i<a_j}$,则只有当排列后${a_j}$再${a_i}$前面才会对答案有贡献(${a_i>a_j}$的情况同…
http://codeforces.com/problemset/problem/696/B (题目链接) 题意 给出一棵树,随机dfs遍历这棵树,求解每个节点的期望dfs序. Solution 考虑对于节点u,其某个儿子节点v的期望是多少. 首先,节点u的儿子的dfs的顺序是其儿子数son[x]的全排列.考虑在排列中有多少个节点在v的前面,不妨设x排在v的前面,那么满足的排列数为:${P_n^{n-2}}$,于是x对v的期望的贡献为:$${\frac{P_n^{n-2}×size[x]} {P…