BZOJ 4481
思路:
等比数列求和 (无穷项)
+线段树找逆序对
//By SiriusRen
#include <bits/stdc++.h>
const int N=;
int n,m,vis[N],now=;
double p,r[N],tree[N*],ans;
struct Node{int x,y;}node[N];
bool cmp(Node a,Node b){if(a.x!=b.x)return a.x<b.x;return a.y<b.y;}
void insert(int l,int r,int pos,int num,double wei){
if(l==r){tree[pos]+=wei;return;}
int mid=(l+r)>>,lson=pos<<,rson=pos<<|;
if(mid<num)insert(mid+,r,rson,num,wei);
else insert(l,mid,lson,num,wei);
tree[pos]=tree[lson]+tree[rson];
}
double query(int l,int r,int pos,int L,int R){
if(L>R)return ;
if(l>=L&&r<=R)return tree[pos];
int mid=(l+r)>>,lson=pos<<,rson=pos<<|;
if(mid<L)return query(mid+,r,rson,L,R);
else if(mid>=R)return query(l,mid,lson,L,R);
else return query(l,mid,lson,L,R)+query(mid+,r,rson,L,R);
}
double w(int now,int t){return p*r[t-]/(-r[vis[node[now].x]]);}
int main(){
scanf("%d%d%lf",&n,&m,&p),r[]=;
for(int i=;i<=;i++)r[i]=r[i-]*(-p);
for(int i=;i<=m;i++)scanf("%d%d",&node[i].x,&node[i].y),vis[node[i].x]++;
std::sort(node+,node++m,cmp);
for(int i=,t=;i<=n;i++,t=)while(node[now].x==i)
t++,insert(,n,,node[now].y,w(now,t)),
ans+=w(now,t)*query(,n,,node[now].y+,n),now++;
printf("%.2f\n",ans);
}
BZOJ 4481的更多相关文章
- bzoj 4481 [ Jsoi 2015 ] 非诚勿扰 —— 期望
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4481 太弱了这种题都要看半天TJ...:https://blog.csdn.net/chai ...
- bzoj 4481: [Jsoi2015]非诚勿扰【期望+树状数组】
首先很容易计算对于一个如意郎君列表里有x个男性的女性,编号排第i位的男性被选的概率是 \[ p*(1-p)^{i-1}+p*(1-p)^{i-1+n}+p*(1-p)^{i-1+n}+- \] \[ ...
- BZOJ 2127: happiness [最小割]
2127: happiness Time Limit: 51 Sec Memory Limit: 259 MBSubmit: 1815 Solved: 878[Submit][Status][Di ...
- BZOJ 3275: Number
3275: Number Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 874 Solved: 371[Submit][Status][Discus ...
- BZOJ 2879: [Noi2012]美食节
2879: [Noi2012]美食节 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 1834 Solved: 969[Submit][Status] ...
- bzoj 4610 Ceiling Functi
bzoj 4610 Ceiling Functi Description bzoj上的描述有问题 给出\(n\)个长度为\(k\)的数列,将每个数列构成一个二叉搜索树,问有多少颗形态不同的树. Inp ...
- BZOJ 题目整理
bzoj 500题纪念 总结一发题目吧,挑几道题整理一下,(方便拖板子) 1039:每条线段与前一条线段之间的长度的比例和夹角不会因平移.旋转.放缩而改变,所以将每条轨迹改为比例和夹角的序列,复制一份 ...
- 【sdoi2013】森林 BZOJ 3123
Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数.第三行包含N个非负整数 ...
- 【清华集训】楼房重建 BZOJ 2957
Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房.每天,这片工地上的房子拆了又建.建了又拆.他经常无聊地看着窗外发呆,数自己能够看到多少栋房子. 为了简化问题,我们考虑这些 ...
随机推荐
- 【16】AngularJS API
AngularJS API API 意为 Application Programming Interface(应用程序编程接口). AngularJS 全局 API AngularJS 全局 API ...
- 添物零基础到大型全栈架构师 不花钱学计算机及编程(预备篇)— C语言编程基础
C语言介绍 C语言基本是每个编程人员必学的一面语言,很好掌握,是理解编程的关键.很多编程语言基于其编写或者基于此语言的衍生品编写. C语言是人机交互的一个基础语言之一,虽然是之一,单一般其实就是唯一 ...
- -sql语句练习50题(Mysql学习练习版)
–1.学生表 Student(s_id,s_name,s_birth,s_sex) –学生编号,学生姓名, 出生年月,学生性别 –2.课程表 Course(c_id,c_name,t_id) – –课 ...
- [Usaco2016 Open]Diamond Collector
题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining diamonds in her s ...
- Spring的Java配置方式
Java配置是Spring4.x推荐的配置方式,可以完全替代xml配置. 1 @Configuration 和 @Bean Spring的Java配置方式是通过 @Configuration ...
- Ubuntu 16.04中CPU轮流100%的问题解决
刚装好Ubuntu 16.04,但是观察各个CPU都是轮流100%,如图所示:
- springboot启动mybatis
初期开发了generator可以根据表结果自动生产实体类.配置文件和dao层代码,可以减轻一部分开发量:后期也进行了大量的优化可以使用注解了,自动管理dao层和配置文件等,发展到最顶端就是今天要讲的这 ...
- 1. CountDiv 数数有几个 Compute number of integers divisible by k in range [a..b].
package com.code; public class Test05_1 { public static int solution(int A, int B, int K) { // handl ...
- 1.7-BGP①
IGP: 包括RIP/EIGRP/OSPF/ISIS/ODR等动态路由协议 运行在同一个AS中, 通过Cost/Metirc来判断路由的优劣(越小越好): AS:自治系统(小) A ...
- [Vue-rx] Watch Vue.js v-models as Observable with $watchAsObservable and RxJS
You most likely already have data or properties in your template which are controlled by third-party ...