面试题数据结构-n个筛子的点数
来源:互联网 发布:香水推荐 知乎 编辑:程序博客网 时间:2024/04/27 16:06
题目:把n个筛子扔在地上,所在筛子朝上的一面的和为s,输入点n,打印出s所有可能出现的概率
#include <iostream>int n;int sum;int stat[100];void solve(int step,int n,int * stat);int solve(int n){solve(1,n,stat);double t;int sum(1);for(int i=0;i!=n;i++){sum=sum*6;}for(int i=0;i!=6*n+1;i++){if(stat[i]!=0){t=(double)stat[i]/(sum);std::cout<<i<<" "<<t<<std::endl;}}return 1;}void solve(int step,int n,int * stat){if(step>n){stat[sum]++;return;}for(int i=1;i!=7;i++){sum+=i;solve(step+1,n,stat);sum-=i;}}int main(){int res=solve(3);getchar();}
- 面试题数据结构-n个筛子的点数
- 剑指offer面试题43:n个筛子的点数
- n个筛子的点数
- 43 n 个筛子 的点数
- 每日一题(70) - n个筛子的点数
- 剑指offer面试题43 n个骰子的点数
- 【剑指offer】面试题43:n个骰子的点数
- 剑指Offer:面试题43 n个骰子的点数
- 面试题43:n个骰子的点数
- 面试题43:n个骰子的点数
- 面试题43:n个骰子的点数(《剑指offer》)
- 面试题47:n个骰子的点数
- 剑指offer-面试题43:n个骰子的点数
- 面试题43:n个骰子的点数
- 剑指offer面试题43:n个骰子的点数
- 剑指Offer面试题43:n个色子的点数
- 面试题43:n个骰子的点数
- 剑指offer-面试题43-n个骰子的点数
- Tictoc的学习重点
- 英文邮件中常见的英语缩写
- 各浏览器对小数处理取整的情况对比【IE、chrome、firefox、safari】
- 30.在从1到n的正数中1出现的次数
- Tomcat启动web项目报Bad version number in .class file (unable to load class ...)错
- 面试题数据结构-n个筛子的点数
- Android Service学习之AIDL, Parcelable和远程服务
- 再续maven 编写自己的maven插件
- xcode在mac里的分界
- java 全排列
- 一个使用STL::string时遇到的诡异bug
- POJ 2828 Buy Tickets
- Internet选项 添加信任站点
- 可执行文件的段