题意:1-n个位置中,每个位置填一个数,问至少有l个数是相同的概率. 可以转化求最多有l-1个数是相同的. dp[i][j]表示前i个位置填充j个位置的方案数,并且要满足上面的条件. 则: dp[i][j]=∑dp[i-1][j-k]*c[m-j+k][k]; 也就是看第i个数,可以不填,填一个位置,两个位置······这样累加过来. 代码如下: import java.math.*; import java.util.*; public class Main { public static v…
[ZOJ]4012 Your Bridge is under Attack 平面上随机n个点,然后给出m条直线,问直线上有几个点 \(n,m \leq 10^{5}\) 由于共线的点不会太多,于是我们可以建KD树出来直接查询,这条直线和某个矩形不相交则不搜索这个子树 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #d…
Water Level Time Limit: 2 Seconds Memory Limit: 65536 KB Hangzhou is a beautiful city, especially the West Lake. Recently, the water level of the West Lake got lower and lower because of the hot weather. The experts think that the West Lake is u…
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是next数组性质的应用嘛”,没错,正是如此. 在ACM的比赛中有些时候会遇到一些题目,可以或必须通过找出数据的规律来编写代码,这里我们专门来讨论下 如何运用KMP中next数组的性质 来寻找一个长数组中的最小循环周期. 先来看一道题 ZOJ 3785 What day is that day? Time…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1015 题意:给出一个n个点的无向图,询问是否为弦图,弦图定义为对于图中任意长度>3的环一定存在环上不相邻的点有边相连(n<=1000) #include <bits/stdc++.h> using namespace std; const int N=1005; int n, m, ihead[N], cnt, tag[N], pos[N]; bool vi…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More i…
=============================以下是最小生成树+并查集====================================== [HDU] How Many Tables 基础并查集★ 小希的迷宫 基础并查集★ &&poj1308 Is It A Tree? 基础并查集★ More is better 基础并查集★ Constructing Roads 基础最小生成树★ 畅通工程 基础并查集★ 还是畅通工程 基础最小生成树★ 畅通工程 基础最小生成树★ 畅通…
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream's world I 基础并查集★212…
[链接] 我是链接,点我呀:) [题意] [题解] 递归一会. 会发现最后肯定是0,1一直循环. 开始循环之后就直接返回结果就好. [代码] #include <bits/stdc++.h> #define ll long long #define rep1(i,a,b) for (int i = a;i <= b;i++) #define rep2(i,a,b) for (int i = a;i >= b;i--) using namespace std; const int N…