light oj 1038 DP求期望
来源:互联网 发布:中网数据股份有限公司 编辑:程序博客网 时间:2024/05/17 00:45
题意:求一个数不断地除以他的因子,直到变成1的时候 除的次数的期望
http://www.lightoj.com/volume_showproblem.php?problem=1038
简单期望题
dp[i]=(dp[a1]+1+dp[a2]+1+..dp[ax]+1)/x;
a1->ax为i的所有因子,移项、化简一下就可以得到dp[i]的递推式了
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;double dp[100010];int main(){ int t,ca=1,n; scanf("%d",&t); dp[1]=0; for(int i=2;i<=100000;i++) { double sum=0; int cnt=0; for(int j=1;j<=sqrt(i*1.0);j++){ if(i%j==0){ sum+=dp[j];cnt++; if(j!=1 && j != i/j) sum+=dp[i/j],cnt++; } } cnt++; sum+=cnt; dp[i]=sum/(cnt-1); } while(t--) { scanf("%d",&n); printf("Case %d: %.20lf\n",ca++,dp[n]); } return 0;}
- light oj 1038 DP求期望
- light oj A Dangerous Maze(概率dp求期望)
- light oj 1038 - Race to 1 Again(概率dp求期望 记忆化搜索)
- Light OJ 1038 Race to 1 Again (期望DP)
- [期望dp+记忆化搜索] light oj 1038 Race to 1 Again
- Light OJ 1027 - A Dangerous Maze(求期望)
- [水+期望dp] light oj 1030 Discovering Gold
- Light OJ 1038(概率DP)
- light oj 1284 - Lights inside 3D Grid(求期望)
- 7_4_A题 A Dangerous Maze题解 [Light oj 1027](求期望)
- Light OJ 1030 - Discovering Gold(期望)
- light oj 1248 - Dice (III)(期望)
- loj 1038(dp求期望)
- 概率dp 求期望
- light oj 1032 数位DP
- light OJ 1205 数位DP
- light OJ 1068 数位DP
- light oj 1140 数位dp
- SDN & OpenFlow 4
- Hypertable - 安装-MapR
- Android中实现滑动翻页—使用ViewFlipper
- 加载器 - Loaders
- 创新工厂面试题详解:共打了多少鱼
- light oj 1038 DP求期望
- 在 Ubuntu 中安装 Internet Explorer
- Android显示GIF图片
- 请手动释放你的资源
- 0.ring0-更改dbgport地址偏移过掉dbgport清0
- POJ 1143 Number Game
- 一著名软件公司的java笔试算法题的答案
- android ListView分页处理
- kernel地址转换的函数