CF-937(D,E)】的更多相关文章

Description To stay woke and attentive(专注的) during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books…
任意门:http://codeforces.com/contest/1114/problem/C C. Trailing Loves (or L'oeufs?) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The number "zero" is called "love" (or "…
Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came…
传送门:Ilya and Escalator 题意:有n个人排队进车厢,每秒只能进一个人,而且第1个人进了后面的人才能进,第一个人每秒进入车厢的概率为p,不进的概率为1-p,求t秒后进入车厢总人数的数学期望. 分析:设dp[i][j]表示第i秒进了j个人的概率,则: dp[i][j]=dp[i-1][j]*(1-p)+dp[i-1][j-1]*p. 注意边界限制: 当j=0时:dp[i][j]=dp[i-1][j]*(1-p) 当j=n时:dp[i][j]=dp[i-1][j]+dp[i-1][…
Devu and his Brother time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given…
这其实是一个简单的区间合并问题,但是我们第一交是过了,后来学长rejudge,我们又TLE了,这一下不仅耽误了我们的时间,也波动到了我们的心情,原先时间是2s,(原oj就是2s),后来改成了1s,我用的O(N*N)的循环直接超时了,这并不可怕,可怕的是我们被这个思路误导了,一直在O(N*N)的基础上优化,交了好多次.......最后才知道没有那么复杂,题目中的样例比较特殊,排序后直接O(N)的枚举就可以了,因为水题罚时多,排名特别靠后,我的心好痛T T.... #include<iostream…
CF 86D 莫队(卡常数) D. Powerful array time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output An array of positive integers a1, a2, ..., an is given. Let us consider its arbitrary subarray al, al + 1..…
清橙A1206.小Z的袜子 && CF 86D(莫队两题) 在网上看了一些别人写的关于莫队算法的介绍,我认为,莫队与其说是一种算法,不如说是一种思想,他通过先分块再排序来优化离线查询问题. 应用范围:一般问题是让你回答多个连续区间上的问题,如果你知道了区间[l,r]的答案.你就可以在O(1)或O(logn)时间内知道[l+1,r].[l,r+1].[l-1,r].[l,r-1]区间的答案,那么你就可以应用莫队算法. 实现方法:数组长度为n,查询个数为m.先读入所有查询,然后把查询[l,r]…
CF Round #600 (Div 2) 解题报告(A~E) A:Single Push 采用差分的思想,让\(b-a=c\),然后观察\(c\)序列是不是一个满足要求的序列 #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int T, n; int a[maxn], b[maxn]; int c[maxn]; int main() { cin >> T; while(T--) { s…
题目链接:http://codeforces.com/contest/1154/problem/G 题意:lcm是最小公倍数,本题就是给你一个数组(可能会重复),要求你判断出那两个数的最小公倍数最小,并输出这两个数的下标 分析:首先想重复,因为重复的话非常好整,最小公倍数就是它自己,所以我们可以先处理一遍,把出现过的重复的数最小的先设为答案(ans). 另外,记得初始化ans,这里有个坑,记得不要初始化为inf,因为最小公倍数是会爆int的,这点要注意. 然后再开始从1-ans遍历,对于每个数,…