23333,还是不会。。%%%http://hzwer.com/6276.html

 #include <bits/stdc++.h>
#define LL long long
#define lowbit(x) x&(-x)
#define inf 0x3f3f3f3f
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
double dp[][];
int n,m,t1,t2;
bool r[],c[];
int main(int argc, char const *argv[])
{
n=ra(); m=ra();
t1=t2=n;
for (int i=; i<=m; i++)
{
int x=ra(),y=ra();
if (!r[x]) r[x]=,t1--;
if (!c[y]) c[y]=,t2--;
}
for (int i=; i<=n; i++)
{
dp[i][]=dp[i-][]+(double)n/i;
dp[][i]=dp[][i-]+(double)n/i;
}
for (int i=; i<=t1; i++)
for (int j=; j<=t2; j++)
{
dp[i][j]=n*n;
dp[i][j]+=i*j*dp[i-][j-];
dp[i][j]+=i*(n-j)*dp[i-][j];
dp[i][j]+=j*(n-i)*dp[i][j-];
dp[i][j]/=(n*n-(n-i)*(n-j));
}
printf("%.10lf\n",dp[t1][t2]);
return ;
}

cf 398B. Painting The Wall的更多相关文章

  1. Painting The Wall 期望DP Codeforces 398_B

    B. Painting The Wall time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. 【CF398B】B. Painting The Wall(期望)

    B. Painting The Wall time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #233 (Div. 2)D. Painting The Wall 概率DP

                                                                                   D. Painting The Wall ...

  4. [Codefoeces398B]Painting The Wall(概率DP)

    题目大意:一个$n\times n$的棋盘,其中有$m$个格子已经被染色,执行一次染色操作(无论选择的格子是否已被染色)消耗一个单位时间,染色时选中每个格子的概率均等,求使每一行.每一列都存在被染色的 ...

  5. codeforces D. Painting The Wall

    http://codeforces.com/problemset/problem/399/D 题意:给出n和m,表示在一个n*n的平面上有n*n个方格,其中有m块已经涂色.现在随机选中一块进行涂色(如 ...

  6. cf 448c Painting Fence

    http://codeforces.com/problemset/problem/448/C 题目大意:给你一个栅栏,每次选一横排或竖排染色,求把全部染色的最少次数,一个点不能重复染色. 和这道题有点 ...

  7. CF398B Painting The Wall 概率期望

    题意:有一个 $n * n$ 的网格,其中 $m$ 个格子上涂了色.每次随机选择一个格子涂色,允许重复涂,求让网格每一行每一列都至少有一个格子涂了色的操作次数期望.题解:,,这种一般都要倒推才行.设$ ...

  8. 【HDU4391】【块状链表】Paint The Wall

    Problem Description As a amateur artist, Xenocide loves painting the wall. The wall can be considere ...

  9. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

随机推荐

  1. Java入门程序“hello,world!”

    1.程序开发步骤说明 开发环境已经搭建完毕,可以开发我们第一个Java程序了. Java程序开发三步骤:编写.编译.运行.(图片介绍)   2.编写Java程序 新建一个普通的记事本,给其命名为Hel ...

  2. C++11并发编程2------线程管理

    本节内容: 启动一个线程 每个程序都至少会有一个线程,main函数是执行入口,我们称之为主线程,其余子线程有各自的入口函数,主线程和子线程同时运行.子线程在std::thread对象创建时启动. 1. ...

  3. titleView发生偏移、titleView与masonry、titleView的设置、titleView的使用

    navigationItem的titleView属性的设置本身是很简单的,容易出问题的原因是自动化布局与frame混用造成的. 本文一步一步的讲解,力求找到问题的起源.如果你也在这块同样遇到问题,不妨 ...

  4. 二 基于java动态数组手写栈

    package dataStucture2.stack; import dataStucture2.array.MyDynamicArray; /** * 基于动态数组手写栈 * 设计时,栈中仅栈顶对 ...

  5. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 辅助类:将页面元素所包含的文本内容替换为背景图

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  6. C#用SQLDMO操作数据库----转载

    C#用SQLDMO操作数据库 sqldmo.dll是随sql server2000一起发布的.sqldmo.dll自身是一个com对象 sqldmo(sql distributed managemen ...

  7. 等级保护2.0-mysql

    控制点 安全要求 要求解读 测评方法 预期结果或主要证据 身份鉴别 a)应对登录的用户进行身份标识和鉴别,身份标识具有唯一性,身份鉴别信息具有复杂度要求并定期更换 应检查MySQL数据库的口令策略配置 ...

  8. python学习 第一章 one day(补)

    python入门 一.编写Hello,World 方法一. 进入解释器,实施输入并获取到执行结果 C:\Users\84535>python Python 3.7.4 (tags/v3.7.4: ...

  9. java并发AtomicIntegerFieldUpdater

    java并发AtomicIntegerFieldUpdater 支持对象的成员变量原子操作类由AtomicIntegerFieldUpdater,AtomicLongFieldUpdater, Ato ...

  10. golang Context for goroutines

    概要 goroutine 的控制 取消控制 超时控制 goroutine 之间的传值 总结 概要 golang 的提供的 channel 机制是基于 CSP(Communicating Sequenc ...