UVA 12161 Ironman Race in Treeland】的更多相关文章

题目大意: 每一条边都有两个权值,val和路径长度d,要保证在val<=m 的条件下,求最长的d. 解题报告: 一开始想错了,后来发现还不如直接暴力点分,思想很套路.. 平时我们统计时,都会用合法减不合法,但这题不是方案统计,需要枚举每一棵子树,这里其实直接暴力枚就行,但是用到了val和d的单调性,首先明确:如果对于两条路径i,j:\(vali>valj,di<dj\) 这样显然不会最优,所以我们就去掉这些路径,剩下的就满足单调性了,d随val增加而增加,这样就可以二分了. 所以我们把子…
题意:求树上的一条费用不超过m的路径,使得总长度尽量大. 人参第一发树分治,紫书上思路讲得比较清晰,这里不再赘述. 实现的时候,用一个类似时间戟的东西,记录结点首次访问的时间,并保存结点序列. 合并的时候用map组织有序表.和Defense Lines类似 复杂度O(nlog^2n) #include<bits/stdc++.h> using namespace std; ; int n,m; ], to[maxn<<], dam[maxn<<], len[maxn&l…
UVA 10627 - Infinite Race option=com_onlinejudge&Itemid=8&page=show_problem&category=516&problem=1568&mosmsg=Submission+received+with+ID+13837674" target="_blank" style="">题目链接 题意:一段跑道,A,B分别在两端,速度为u.v,两个人跑到还…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
UVA 11762 - Race to 1 题意:给定一个n,每次随即选择一个n以内的质数,假设不是质因子,就保持不变,假设是的话.就把n除掉该因子,问n变成1的次数的期望值 思路:tot为总的质数.cnt为质因子个数,那么f(n)=(1−cnt/tot)∗f(n)+∑f(n/prime)∗(1/tot),然后利用记忆化搜索去做就可以 代码: #include <stdio.h> #include <string.h> const int N = 1000005; int t, n…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2862 晕 多加了一个# wa了N久  细节呀 代码及其注释: #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<cmath>…
数学期望/马尔可夫过程 DP/记忆化搜索 刘汝佳老师白书上的例题…… //UVA 11762 #include<vector> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define rep(i,n) for(int i=0;i<n;++i) #define F(i,j,n) for(i…
引用自:http://hi.baidu.com/aekdycoin/item/be20a91bb6cc3213e3f986d3,有改动 题意: 已知D, 每次从[1,D] 内的所有素数中选择一个Ni, 如果D = 0(mod Ni), 那么D /= Ni,否则D不变(可以看成是每一轮 D/= GCD(D,Ni) ) 思路: 概率DP 令 dp[ i ] 表示 D = i 的时候的期望, 即从i 转移到1 的次数期望. 我们有 p = kcnt[ i ] / cnt[ i ]; kcnt[ i ]…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3185 题意: A.B两人赛马,最终名次有3种可能:并列第一:A第一B第二:B第一A第二.输入n(1≤n≤1000),求n人赛马时最终名次的可能性的个数除以10056的余数. 分析: 设答案为f(n).假设第一名有i个人,有C(n,i)种可能性,接下来有f(n-i)种可能性,因此答案…
Disky and Sooma, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded and wandered around, even in their holidays. They passed several months in this way. But everything has an end. A holy person, Munsiji came into their…