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 ...
随机推荐
- Mysql表基本操作
一. 创建表的方法 语法:create table 表名( 属性名数据类型完整约束条件, 属性名数据类型条完整约束件, ......... 属性名数据类型 ); (1)举例:1 create tabl ...
- 修改ubuntu按下关机键触发的事件
gsettings set org.gnome.settings-daemon.plugins.power button-power shutdown will change your the beh ...
- getchar(),gets(),scanf()的差异比较
scanf( )函数和gets( )函数都可用于输入字符串,但在功能上有区别.若想从键盘上输入字符串"hi hello",则应该使用gets()函数. gets可以接收空格:而sc ...
- nginx学习之一
http://tengine.taobao.org/book/chapter_02.html
- 【BZOJ 1068】[SCOI2007]压缩
Description 给 一个由小写字母组成的字符串,我们可以用一种简单的方法来压缩其中的重复信息.压缩后的字符串除了小写字母外还可以(但不必)包含大写字母R与M,其中M 标记重复串的开始,R重复从 ...
- C++中的运算符优先级
1 () [] . ->2 ! ~ -(负号) ++ -- &(取变量地址)* (type)(强制类型) sizeof 3 * / % 4 + ...
- c语言函数指针的理解与使用
1.函数指针的定义 顾名思义,函数指针就是函数的指针.它是一个指针,指向一个函数.看例子: A) char * (*fun1)(char * p1,char * p2); B) char * *fun ...
- adb shell 出现 error :
首先,确保 adb 服务有起来 adb kill-server adb start-server其次,确保 adb devices 可以找到设备
- 2434: [Noi2011]阿狸的打字机 - BZOJ
Description 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到一台老式的打字机.打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P'两个字母. 经阿狸研究发现,这个打字机是这样工作的 ...
- Can't update table 'test_trigger' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
[Err] 1442 - Can't update table 'test_trigger' in stored function/trigger because it is already used ...