栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3766 Hexagon Coin Toss

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3766 Hexagon Coin Toss

#include <iostream>#include <sstream>#include <map>#include<algorithm>#include<ctime>#include<stdio.h>#include<cmath>#include<algorithm>#include<cstring>#include<ctime>using namespace std;double eps=0;double js(double k){return k*k*3*sqrt(3.0)/2;}int main(){int n,m,k,cas=1;double r,pi=acos(-1.0);while(cin>>n>>m>>k>>r&&n){int lk;if(n!=k)lk=n;else lk=n-1;if(m&1)lk=k;int tot=(n*2-1)*(m/2);if(m&1)tot+=k;int a[3]={0};a[0]+=k+lk+(m+1)*2;a[2]=(m-1)*3*(n+n-3);a[1]=(6*tot-a[0]-a[2]);double p[3];double x=sqrt(3.0)/2;p[0]=js((x-r)/x);p[2]=pi*r*r+r*r*sqrt(3.0)*2;p[1]=js(1)-p[0]-p[2];p[0]/=6*tot*js(1.0)/100;p[1]/=6*tot*js(1.0)/100;p[2]/=6*tot*js(1.0)/100;printf("Case %d:n",cas++);printf("Probability of covering 1 hexagon   = %.3lf percent.n",a[2]*p[0]+a[1]*(p[0]+p[1]/2)+a[0]*(p[0]+p[1]+p[2])+eps);printf("Probability of covering 2 hexagons  = %.3lf percent.n",a[2]*p[1]+a[1]*(p[2]+p[1]/2)+eps);printf("Probability of covering 3 hexagons  = %.3lf percent.n",a[2]*p[2]+eps);cout<<endl;}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/375848.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号