思路:

等比数列求和 (无穷项)

+线段树找逆序对

//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的更多相关文章

  1. bzoj 4481 [ Jsoi 2015 ] 非诚勿扰 —— 期望

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4481 太弱了这种题都要看半天TJ...:https://blog.csdn.net/chai ...

  2. bzoj 4481: [Jsoi2015]非诚勿扰【期望+树状数组】

    首先很容易计算对于一个如意郎君列表里有x个男性的女性,编号排第i位的男性被选的概率是 \[ p*(1-p)^{i-1}+p*(1-p)^{i-1+n}+p*(1-p)^{i-1+n}+- \] \[ ...

  3. BZOJ 2127: happiness [最小割]

    2127: happiness Time Limit: 51 Sec  Memory Limit: 259 MBSubmit: 1815  Solved: 878[Submit][Status][Di ...

  4. BZOJ 3275: Number

    3275: Number Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 874  Solved: 371[Submit][Status][Discus ...

  5. BZOJ 2879: [Noi2012]美食节

    2879: [Noi2012]美食节 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1834  Solved: 969[Submit][Status] ...

  6. bzoj 4610 Ceiling Functi

    bzoj 4610 Ceiling Functi Description bzoj上的描述有问题 给出\(n\)个长度为\(k\)的数列,将每个数列构成一个二叉搜索树,问有多少颗形态不同的树. Inp ...

  7. BZOJ 题目整理

    bzoj 500题纪念 总结一发题目吧,挑几道题整理一下,(方便拖板子) 1039:每条线段与前一条线段之间的长度的比例和夹角不会因平移.旋转.放缩而改变,所以将每条轨迹改为比例和夹角的序列,复制一份 ...

  8. 【sdoi2013】森林 BZOJ 3123

    Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数.第三行包含N个非负整数 ...

  9. 【清华集训】楼房重建 BZOJ 2957

    Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房.每天,这片工地上的房子拆了又建.建了又拆.他经常无聊地看着窗外发呆,数自己能够看到多少栋房子. 为了简化问题,我们考虑这些 ...

随机推荐

  1. css实现圆角效果

    源码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> & ...

  2. vue axios请求超时,设置重新请求的完美解决方法

    //在main.js设置全局的请求次数,请求的间隙 axios.defaults.retry = 4; axios.defaults.retryDelay = 1000; axios.intercep ...

  3. SHA256兼容性

    SHA-2是一个加密哈希(Cryptographic Hash)函数的一个集合,包括SHA-224,SHA256和SHA-512.在SHA-256中的256代表哈希(Hash)输出或者摘要的位尺寸(即 ...

  4. [luoguP2858] [USACO06FEB]奶牛零食Treats for the Cows(DP)

    传送门 f[i][j][k] 表示 左右两段取到 i .... j 时,取 k 次的最优解 可以优化 k 其实等于 n - j + i 则 f[i][j] = max(f[i + 1][j] + a[ ...

  5. 邮票(codevs 2033)

    题目描述 Description 已知一个 N 枚邮票的面值集合(如,{1 分,3 分})和一个上限 K —— 表示信封上能够贴 K 张邮票.计算从 1 到 M 的最大连续可贴出的邮资. 例如,假设有 ...

  6. poj——2891 Strange Way to Express Integers

    Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 16839 ...

  7. Ubuntu 16.04设置文件夹试图永久以列表显示

    图片来自:http://forum.ubuntu.org.cn/viewtopic.php?p=2043385

  8. Ubuntu 16.04安装BleachBit清理系统垃圾文件

    在LInux下不同于Windows会产生系统垃圾,但是Linux会产生安装软件时的依赖包,比如卸载一个软件,其依赖包是不会删除的.但是可以通过以下命令解决: #清理旧版本的软件缓存 sudo apt- ...

  9. Domino Server installation on Linux (Centos or Redhat) – something somewhere

    something somewhere welcome in there…:) Just another techki site howto / Linux / Lotus Domino 0 Domi ...

  10. python基础学习之02 序列

    #encoding=utf-8 import math a=[1,23,4,5,6] print a a[1:1]=[2,3,5] print a a a[1]='a' print a a[1]={1 ...