lightoj1038
2024-08-25 22:56:20
//Accepted 2860 KB 16 ms //概率 //对于n,假设n变成1的期望步数为p(n) //则p(n)=1/t*sum((1+p(d))) d|n //解得:p(n)=1/(t-1)*(t+sum(p(d))) d|n d!=n; //下面我们可以改造筛素数的方法,对于每个d,看他整除那些数 #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <cmath> #include <algorithm> using namespace std; /** * This is a documentation comment block * 如果有一天你坚持不下去了,就想想你为什么走到这儿! * @authr songt */ ; double f[imax_n]; int t[imax_n]; void pre() { ;i<imax_n;i++) { f[i]=; t[i]=; } f[]=; ;i<imax_n-;i++) { f[i]=(f[i]+)/t[i]; *i;j<imax_n-;j+=i) { f[j]+=+f[i]; t[j]++; } } } int n; int main() { pre(); int T; ; scanf("%d",&T); while (T--) { scanf("%d",&n); printf("Case %d: %.6lf\n",++t,f[n]); } ; }
最新文章
- 解决:Angular-cli:执行ng-build --prod后,dist文件里无js文件、文件未压缩等问题
- Hbase之缓存扫描加快读取速度
- AndrdoidStudio 2个jar包引起的异常Duplicate files copied in APK META-INF/LICENSE.txt
- System Generator入门笔记
- JavaScript Tutorial
- HW4.40
- MySQLD 配置
- applet授权数字签名
- NYOJ 57 6174问题
- 又把JDK改回JDK1.8的过程
- git 更新远程分支列表
- 【你的职业规划】web前端的职业发展方向及学习攻略【转载】
- Redis数据库的安装与基本应用
- spoj Prime Generator
- hdu-1173(最短距离)
- 谈谈hadoop集群启动时进程那回事
- ativemq使用教程
- POJ 1703 Find them, Catch them(确定元素归属集合的并查集)
- mysql基础操作学习笔记(一)
- Openstack块存储cinder安装配置