题目:有2中面条各n碗,每次抛硬币判断吃哪一种(到一种吃完为止),问抛硬币的数学期望。
分析:动态规划,概率dp。求出每种结束状态(即,有一种吃完)的概率,分别乘以步长即为期望。
大黄解法:状态位剩余的碗数,逆向求解,状态方程:
DP[ i ][ j ] = (DP[ i-1 ][ j ]+DP[ i ][ j-1 ])/2 + 1 ...
分类:
其他好文 时间:
2014-10-04 21:41:47
阅读次数:
193
# include
# include
# include
# include
using namespace std;
int main()
{
int n,i,j,k;
int c1[310],c2[310];
while(~scanf("%d",&n),n)
{
for(i=0;i<=n;i++)
{
...
分类:
其他好文 时间:
2014-10-03 11:59:44
阅读次数:
246
Problem Description
Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in ...
分类:
其他好文 时间:
2014-10-03 02:05:13
阅读次数:
356
Gold Coins
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 21155 Accepted: 13265
Description
The king pays his loyal knight in gold coins. On the first day of his service, the...
分类:
其他好文 时间:
2014-09-27 14:29:09
阅读次数:
200
题意: 给定N个面值,a1..an,每种面值都有c1..cn个,问从1..m的面值中,有多少个可以用已经给定的面值组成?分析: 还记得“多重组合数”问题么? DP[K][N]——用前N种数字组成K,第N种可以剩下最多多少个。 证明分析就不给出了,见前面的博文吧。时间复杂度为K*N这道题...
分类:
其他好文 时间:
2014-09-26 19:41:48
阅读次数:
138
题目:有m个钱币,有两种价值(xi,yi),现在要求组成面值sum(x)^2+sum(y)^2=s^2的最少硬币数。
分析:dp,二维安全背包。和以为背包相同,只是容量现在是二维的,按递增序枚举两个容量即可;
求解时,枚举所有x^2+y^2=s^2的x和y,取最小即可。
说明:最近开始练习dp(⊙_⊙)。
#include
#include
#include ...
分类:
其他好文 时间:
2014-09-19 15:44:05
阅读次数:
181
Crossing
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 1564
Accepted: 726
Description
Wintokk has collected a huge amount of coins at THU. One day he had...
分类:
其他好文 时间:
2014-09-18 22:19:04
阅读次数:
309
前年的省赛题,难点在于这个石头的推移不太好处理后来还是看了阳神当年的省赛总结,发现这个石头这里,因为就四五个子,就暴力dfs处理即可。先把石头当做普通障碍,进行一遍全图的dfs或者bfs,找到可以找的点,然后dfs每次探索新区域的新点即可,想通了这里很好做了#include #include #in...
分类:
其他好文 时间:
2014-09-09 17:57:19
阅读次数:
270
题目链接Yet another game from chef. Chef gives youNcards andMbags. Each of theNcards has an integer written on it. Now chef asks you to close your eyes an...
分类:
其他好文 时间:
2014-09-04 22:15:00
阅读次数:
291