P5242 [USACO19FEB]Cow Dating】的更多相关文章

题目链接 题意分析 首先我们可以得出计算公式 \[s_i=\prod_{k=1}^i(1-p_k)\] \[f_i=\sum_{k=1}^i\frac{p_k}{1-p_k}\] 那么 \[ans(i,j)=\frac{s_r}{s_{l-1}}{f_r-f_{l-1}}\] 强行枚举 \(O(n^2)\) 我们冷机观察一波发现 可以使用尺取法 然后优化成了\(O(n)\) CODE: #include<iostream> #include<cstdio> #include<…
这道题很有意思. 不难发现,对于一个区间 \([l, r]\),恰好只有一个奶牛接受邀请的概率为 \[\prod_{i=l}^r(1-p_i) \cdot \sum_{i=l}^r \frac {p_i} {1-p_i}\] 设 \(m_a = \prod_{i=1}^a(1-p_i),\,s_a=\sum_{i=1}^a\frac{p_i}{1-p_i}\),那么上面的式子可以表示为 \[\frac{m_r}{m_{l - 1}}\cdot (s_r-s_{l-1})\] 这个式子是凸的.它具…
Luogu5242 通过观察数据,我们可以发现,右端点的取值是单调递增的.于是,我们可以极限一波,用一个双指针法,类似于队列. 右端点的取值满足以下公式: (1-p1)(1-p2)..(1-pn) * (p1/(1-p1) + p2/(1-p2) + ... + pn/(1-pn)) 记录两个变量,表示和和积即可. tmp1为积,tmp2为和 当任何一个 p 大于 0.5 的时候,选择一段的答案不比选择这一个的答案大.因此直接特判这种情况. 常规化式子 #include<bits/stdc++.…
原题戳这里 题解 显然原题等价于让我们求这个式子\(\prod\limits_{i=l}^{r}(1-p_i)\sum\limits_{i=l}^{r}\frac{p_i}{1-p_i}\)的最大值是多少 打打表,或者直观上感受一下,这东西是个凸壳,进一步观察,你会发现随着左端点的右移,最优决策点也在右移,于是拿个\(two\ pointer\)搞一搞就好了 凸性的证明在代码下面QWQ 代码: #include <bits/stdc++.h> using namespace std; #def…
震惊,蒟蒻学树剖第二天就打题解 所以说,理解之后树剖这种东西其实难度真心不大.至少这种模板题都可以秒切的 这里推荐一个博客: 树剖详解 蒟蒻就是在这个博客上学到的 如果想看我自己写的总结,请点 我的博客 这个链接(虽然这个是写给自己看的,理解难度应该不小) 树剖的方法在博客上都有了,在这里不细讲,专注讲一下这题的实现: \(dfs\) 请使用博客上的方法,这题需要做的只是照搬 首先,我们可以发现,这题跟普通的树剖基本上一样.唯一的区别就是他要使用 \(xor\) .那么,我们发现, \(xor\…
看到各位大佬们已经把其他的东西讲的很明白了,我这个 juruo 就讲一讲最基本的树链剖分吧. 0.树剖是什么?能吃吗? 不能吃 树剖是树链剖分的简称,我们一般说的树剖其实指重链剖分.当然,还有一种长链剖分我不会,但是据说不常用. 树链剖分能够把树剖分成许多链,这样就可以用维护区间的方式维护一棵树. 1.怎么剖分 先引入一些概念: 重儿子:一棵树最大的子树叫重儿子.例如这棵树中3就是1的重儿子:很明显,一棵树的重儿子是唯一的.什么?有多棵子树的大小相同?那就随便选一个呗. 轻儿子:除了重儿子都是轻…
ri,被黄题虐. 思路:贪心?? 提交:2次 错因:没有特判 题解: 先排序. 最小代价:固定区间长度为\(n\),我们扫一遍数组看区间最多包含几个数,设为 \(mx\) ,答案就是\(n-mx+1\):然而还要特判一种,见下. 此时答案是2,但是我们会算成1 最大代价:考虑一定是往一边缩的感觉,于是是端点先跳到一边的里面,然后这一边开始往里缩,直到缩成n 所以答案是\(\max(a[n-1]-a[1]+1,a[n]-a[2]+1)-(n-1)+1\),最后的加一是刚开始端点往里跳的代价. 代码…
传送门 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 80273   Accepted: 25290 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 10…
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdio> #include <algorithm> using namespace std; ]; int n,m,d,l,ans; int main() { scanf("%d%d%d%d",&n,&m,&d,&l); ;i<=n;i+…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2838 Cow Sorting Problem Description Sherlock's N (1 ≤ N ≤ 100,000) cows are lined up to be milked in the evening. Each cow has a unique "grumpiness" level in the range 1...100,000. Since grumpy cow…
[BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 试题描述 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发现她们已经结成了几个"群".每只奶牛在吃草的时候有一个独一无二的位置坐标Xi,Yi(l≤Xi,Yi≤[1..10^9]:Xi,Yi∈整数.当满足下列两个条件之一,两只奶牛i和j是属于同一个群的:   1.两只奶牛的曼哈顿距离不超过C(1≤C≤10^9),即lXi - xil+IYi - Y…
细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点,可有子节点.Group { UniqueID Group_0         //Gourp名称DataVariance STATIC   //不知道用来干嘛,一般都是staticcullingActive TRUE      //参与culling?num_children 1         …
Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13016   Accepted: 8598 Description The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard…
在linux下,虚拟机的选择方式有很多,比如vmware for linux,virtual box,还有qemu,在以前,使用qemu的人不多,主要是使用起来有些麻烦,但现在随着Openstack的兴起,qemu也得到了很大的发展,现在在Fedora下使用qemu+kvm性能还是很好的,如果再加上spice,就更不错了.但今天还是主要讲讲qemu下使用的几种镜像格式吧! 1. raw raw格式是最简单,什么都没有,所以叫raw格式.连头文件都没有,就是一个直接给虚拟机进行读写的文件.raw不…
Cow Marathon Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 3195   Accepted: 1596 Case Time Limit: 1000MS Description After hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has com…
http://poj.org/problem?id=2184   Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to the public that they are both smart and fun. In order to do this,…
Silver Cow Party Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12674   Accepted: 5651 Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X …
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 77420   Accepted: 24457 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00…
Cow Exhibition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12420   Accepted: 4964 Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 73973   Accepted: 23308 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00…
4422: [Cerc2015]Cow Confinement Time Limit: 50 Sec  Memory Limit: 512 MBSubmit: 61  Solved: 26[Submit][Status][Discuss] Description 一个10^6行10^6列的网格图,上面有一些牛.花和一些矩形围栏,围栏在格子的边界上,牛和花在格子里,牛只能向下或向右走,牛也不能穿过围栏和地图边界,求每头牛它能到达的花的数量.注意栅栏不会相交     Input 第一行一个数f表示矩…
题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N (1 ≤ N ≤ 1,000) pastures, conveniently numbered 1...N. The pastures are connected by M (1 ≤ M ≤ 10,000) one-way paths (no path connects a pasture to…
Best Cow Line   Time Limit: 1000MS      Memory Limit: 65536K Total Submissions: 16104    Accepted: 4547 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arrang…
Cash Cow Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2721 Years before Candy Crush became the wildly popular game that may lead developer Saga to a multi-billi…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 38263   Accepted: 11891 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 45648   Accepted: 14310 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00…
链接 Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Eac…
Description The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their finest gowns, complete with corsages and new shoes. They know that tonight they will each try to perform the Round Dance. Only cows can perform the…
B - Catch That Cow Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same num…
http://poj.org/problem;jsessionid=F0726AFA441F19BA381A2C946BA81F07?id=3617 Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and her…