hdu 6052 To my boyfriend】的更多相关文章

说实话不是很懂按题解怎么写,思路来源于 http://blog.csdn.net/calabash_boy/article/details/76272704?yyue=a21bo.50862.201879 写起来倒是挺短的. /* HDU 6052 - To my boyfriend [ 分析,期望 ] | 2017 Multi-University Training Contest 2 题意: 给出一个N*M的数字矩阵 求子矩阵的不同数字的个数的期望 限制 N,M <= 100 分析: 统计单…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6052 [题目大意] 给出一个数字矩阵,求子矩阵期望数字种数 [题解] 我们统计[x,y]为其所表示的数字的最左上方的矩形数量,即该格子的贡献值, 我们用悬线法将上边界上移,调整左右边界保证[x,y]为数字左上边界, 那么x及其以下的部分都可以作为下边界,顺序统计即可, 由于障碍点的顺序设置保证了二维的偏序性,不会出现重复统计贡献. [代码] #include <cstdio> #include…
题目 OvO click here http://acm.hdu.edu.cn/showproblem.php?pid=6052 (2017 Multi-University Training Contest - Team 2 - 1008) 解 分开考虑每种颜色 pre[i][j]代表第j列最近一个i颜色的行数,ppre是次近 calcu(li,ji,x,y,clr)表示从col=li到col=ri,计算(x,y)点对mp[x][y]=clr颜色有贡献的矩形的个数(其实并不是,准确说是(n-i…
To my boyfriend Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1246    Accepted Submission(s): 556 Problem Description Dear LiaoI never forget the moment I met with you. You carefully asked me:…
题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: "I have a very difficult problem. Can you teach me?". I replied with a smile, "of course". You replied:"Given a matrix, I randoml…
题意:对于一个n*m的方格,每个格子中都包含一种颜色,求出任意一个矩形包含不同颜色的期望. 思路: 啊啊啊啊啊,补了两天,总算A了这道题了,简直石乐志,前面的容斥还比较好写,后面的那个>13那个最开始思路错了,然后 竟然只有一组样例没有过???? 然后以为是哪里写挂爆long long了.后来想了好久,明明思路完全就是错的! 最开始想的 是直接找那个值的外围的就好了, 忽略了里面的,然后其实问题是转化成在01矩阵中找全1矩阵的个数,本来兴冲冲的写了一发, 发现和正方形DP不是一个东西.... 感…
-----------题目链接------------- 题目描述: 给定一个矩阵,定义\(f(A)\) 为矩阵中不同元素的个数.现在要求\(f(A)\)的期望. 解法: 首先来暴力的,复杂度大约:\(O(n^{4})\).枚举原矩阵中每一个数字的贡献数, LL submatix(int x,int y) { LL res=1ll*x*(x+1)*y*(y+1)/4; return res; } LL find(int x,int y) { LL res; int L=1,R; int val=…
题意略. 思路:我们单独考虑每种颜色的贡献,颜色c对答案的贡献 == 含有c的矩形个数,这就是在考查我们计数的能力,暴力可过. #include<bits/stdc++.h> #define maxn 105 using namespace std; int color[maxn][maxn]; int n,m; double calcu(int x,int y){ ,r = m + ,c = color[x][y]; ; ;--i){ if(color[i][y] == c &&am…
起因:在2020年一场HDU多校赛上.有这么一题没做出来. 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6829 题目大意:有三个人,他们分别有X,Y,Z块钱(1<=X,Y,Z<=1e6),钱数最多的(如果不止一个那么随机等概率的选一个)随机等可能的选另一个人送他一块钱.直到三个人钱数相同为止.输出送钱轮数的期望,如果根本停不下来(希望のはな繋いだ绊が~),输出-1. 做题过程:很显然我们可以得到一个DP想法dp[i][j]表示钱第二多的和第三…
HDU 3081 Marriage Match II (网络流,最大流,二分,并查集) Description Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as…
HDU 3081 Marriage Match II (二分图,并查集) Description Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as so many…
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2262    Accepted Submission(s): 673 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea…
Marriage Match II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4021    Accepted Submission(s): 1309 Problem Description Presumably, you all have known the question of stable marriage match. A…
Marriage Match III Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1971    Accepted Submission(s): 583 Problem Description Presumably, you all have known the question of stable marriage match.…
Marriage Match II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3558    Accepted Submission(s): 1158 Problem Description Presumably, you all have known the question of stable marriage match. A…
Marriage Match III Time Limit: 4000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 327764-bit integer IO format: %I64d      Java class name: Main   Presumably, you all have known the question of stable marriage match. A girl…
Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7194    Accepted Submission(s): 3345 Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了.显然,作为多年拼搏的商人,XHD不会坐以待毙的.  一天,当他正在苦思冥想解困良策的…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格线满足两侧分别是海洋和陆地 这道题很神 首先考虑一下,什么情况下能够对答案做出贡献 就是相邻的两块不一样的时候 这样我们可以建立最小割模型,可是都说是最小割了 无法求出最大的不相同的东西 所以我们考虑转化,用总的配对数目 - 最小的相同的对数 至于最小的相同的对数怎么算呢? 我们考虑这样的构造方法:…
Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4569 Description Let f(x) = a nx n +...+ a 1x +a 0, in which a i (0 <= i <= n) are all known integers. We call f(x) 0 (mod…
The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4006 Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a nu…
How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1796 Description   Now you get a number N, and a M-integers set, you should find out how many integers which are sm…
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pid=4418 读了一遍题后大体明白意思,但有些细节不太确定.就是当它处在i点处,它有1~m步可以走,但他走的方向不确定呢.后来想想这个方向是确定的,就是他走到i点的方向,它会继续朝着这个方向走,直到转向回头. 首先要解决的一个问题是处在i点处,它下一步该到哪个点.为了解决方向不确定的问题,将n个点转…
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/article/details/22569639 这个题目本身简单,我的想法也很easy,但是发生在测试上,我把memset的参数搞错了,第三个是sizeof(a), 比如说int a[10],第三个参数应该是sizeof(10),也就是40,而我传的是10,导致后面的测试,都是答案错误,也就是后面的数据,初始…
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟  a.     p(r)=   R'/i   rel(r)=(1||0)  R是前n次输入有关URL的个数  R'是后n次已经输入有关URL的个数 b.   另加:输入 istringstream #include<iostream> #include<sstream> //istringstream 必须包含这个头文件 #include<string&g…
http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:求最近祖先节点的权值和 思路:LCA Tarjan算法 #include <stdio.h> #include <string.h> #define maxn 40005 ],pos,dist[maxn],f[maxn]; bool vis[maxn]; struct Edge{ int to,val,next; }edge[maxn*]; void add(int u,int v,…
http://acm.hdu.edu.cn/showproblem.php?pid=1429 一个广搜的简单题吧,不过有意思的事这个题目用到了位运算,还有就是很恶心的MLE #include <stdio.h> #include <string.h> #include <queue> using namespace std; int m,n,t; ][]; ][][<<]; ][] = {-,,,,,-,,}; struct note{ int x,y,st…
http://acm.hdu.edu.cn/showproblem.php?pid=1878 题意:就是判断这个图是不是一个欧拉回路的一个题, 思路:我觉得这个题可以用并查集判环加上判断每个点的度就行了 #include <stdio.h> #include <string.h> #include <queue> using namespace std; ]; ]; int Find(int x) { int _x=x,_b; while( _x != belg[ _x…
hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem/3223/ 思路:主要是用了一个Meisell-Lehmer算法模板,复杂度O(n^(2/3)).讲道理,我不是很懂(瞎说什么大实话....),下面输出请自己改 #include<bits/stdc++.h> using namespace std; typedef long long LL;…
链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2191 思路:多重背包模板题 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <algorithm> using namespace std; int money,type; ],weigh[],num[],dp[]; i…