POJ 3440 Coin Toss(求概率)
题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率。
思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次。。。。。
//
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#define PI acos(-1.0) using namespace std ; int main()
{
int k;
double a1,a2,a3,a4,sum;
double c,m,n,t;
scanf("%d",&k) ;
for(int i = ; i <= k ; i++){
scanf("%lf %lf %lf %lf",&m,&n,&t,&c) ;
sum = m*n*t*t;
a1 = (t-c)*(t-c)*n*m+(c*(t-c)+c*c/4.0)*+c*(t-c)*(n+m-) ;
a2 = (m-)*n*t*c+(n-)*m*t*c-*(m-)*(n-)*c*c;
a3 = (m-)*(n-)*c*c*(-PI/);
a4 = (m-)*(n-)*c*c*PI/;
printf("Case %d:\n",i);
printf("Probability of covering 1 tile = %.4f%%\n",*a1/sum);
printf("Probability of covering 2 tiles = %.4f%%\n",*a2/sum);
printf("Probability of covering 3 tiles = %.4f%%\n",*a3/sum);
printf("Probability of covering 4 tiles = %.4f%%\n",*a4/sum);
printf("\n");
}
return ;
}
POJ 3440 Coin Toss(求概率)的更多相关文章
- POJ 3440 Coin Toss(概率)
题目链接 概率问题,像是概率论上学的均匀分布,是不是呢,忘了... 概率同面积有关系,我写的各种搓,然后此题格式十分变态,=前有的时候俩空格,有的时候一个空格.代码各种搓. #include < ...
- poj 3440 Coin Toss 概率问题
这题主要是推导数学公式!!! 将概率问题转化为圆心所在的面积! 代码如下: #include<iostream> #include<stdio.h> #include<a ...
- UVA 10328 - Coin Toss dp+大数
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- poj 1474 Video Surveillance - 求多边形有没有核
/* poj 1474 Video Surveillance - 求多边形有没有核 */ #include <stdio.h> #include<math.h> const d ...
- poj 1279 Art Gallery - 求多边形核的面积
/* poj 1279 Art Gallery - 求多边形核的面积 */ #include<stdio.h> #include<math.h> #include <al ...
- hdu3076--ssworld VS DDD(概率dp第三弹,求概率)
ssworld VS DDD Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- UVA 10328 Coin Toss
Coin Toss Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: ...
- 关于有向图走“无限次”后求概率/期望的口胡/【题解】HNCPC2019H 有向图
关于有向图走"无限次"后求概率/期望的口胡/[题解]HNCPC2019H 有向图 全是口胡 假了不管 讨论的都是图\(G=(V,E),|V|=n,|E|=m\)上的情况 " ...
- POJ 3080 Blue Jeans (求最长公共字符串)
POJ 3080 Blue Jeans (求最长公共字符串) Description The Genographic Project is a research partnership between ...
随机推荐
- Android 悬浮窗 WindowManager WindowManager.LayoutParamas
前方高清大图~~~~ 绘制的图片资源: // draw bitmap BitmapDrawable bmpDraw = (BitmapDrawable) getResources().getDrawa ...
- MDX : Non Empty v/s NonEmpty
MDX : Non Empty v/s NonEmpty User Rating: / 50 PoorBest Written by Jason Thomas Friday, 07 May 20 ...
- JavaScript移除数组元素减少长度的方法
JavaScript移除数组元素减少长度的方法,代码如下: //数组移除长度方法 var array=[]; array[0]="张三"; array[1]="李四& ...
- Python-Day5 常用模块学习
一.模块介绍 通俗点说,就是把常用的一些功能单独放置到一个.py文件中,方便其他文件来调用,这样的一个文件可以称为一个模块. 模块分为三种: 自定义模块 内置标准模块(又称标准库) 开源模块 二.导入 ...
- 1103. Integer Factorization (30)
The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positi ...
- 爱重启的windows,伤不起
.
- java之jar命令详解
1. JAR 文件包 JAR 文件就是 Java Archive File,顾名思意,它的应用是与 Java 息息相关的,是 Java 的一种文档格式.JAR 文件非常类似 ZIP 文件——准确的说, ...
- 【js】随机数
<script> function GetRandomNum(Min,Max){ var Range = Max - Min; var Rand = Math.random() ...
- asp.net 多个域名重定向,在web.Config中配置
一个网站有多个域名,但是需要在访问其中某个域名之后跳转到另一域名. Web.config 中配置 </system.webServer> <!--重定向 域名 开始--> &l ...
- Qt html 界面混合编程
Qt部分 项目文件.pro Qt += webenginewidgets webchannel 创建WebEngineView #include <QtWebEngineWidgets> ...