poj3440--Coin Toss(几何上的概率)
Time Limit: 5000MS | Memory Limit: 65536K | |
Total Submissions: 3946 | Accepted: 1076 |
Description
In a popular carnival game, a coin is tossed onto a table with an area that is covered with square tiles in a grid. The prizes are determined by the number of tiles covered by the coin when it comes to rest: the more tiles it covers, the better the prize. In the following diagram, the results from five coin tosses are shown:
In this example:
- coin 1 covers 1 tile
- coin 2 covers 2 tiles
- coin 3 covers 3 tiles
- coin 4 covers 4 tiles
- coin 5 covers 2 tiles
Notice that it is acceptable for a coin to land on the boundary of the playing area (coin 5). In order for a coin to cover a tile, the coin must cover up a positive area of the tile. In other words, it is not enough to simply touch the boundary of the tile. The center of the coin may be at any point of the playing area with uniform probability. You may assume that (1) the coin always comes to a rest lying flat, and (2) the player is good enough to guarantee that the center of the coin will always come to rest on the playing area (or the boundary).
The probability of a coin covering a certain number of tiles depends on the tile and coin sizes, as well as the number of rows and columns of tiles in the playing area. In this problem, you will be required to write a program which computes the probabilities of a coin covering a certain number of tiles.
Input
Output
Separate the output of consecutive cases by a blank line.
Sample Input
3
5 5 10 3
7 4 25 20
10 10 10 4
Sample Output
Case 1:
Probability of covering 1 tile = 57.7600%
Probability of covering 2 tiles = 36.4800%
Probability of covering 3 tiles = 1.2361%
Probability of covering 4 tiles = 4.5239% Case 2:
Probability of covering 1 tile = 12.5714%
Probability of covering 2 tiles = 46.2857%
Probability of covering 3 tiles = 8.8293%
Probability of covering 4 tiles = 32.3135% Case 3:
Probability of covering 1 tile = 40.9600%
Probability of covering 2 tiles = 46.0800%
Probability of covering 3 tiles = 2.7812%
Probability of covering 4 tiles = 10.1788%
Source
题意:
就是问一个半径为r的硬币扔在r*c由t*t正方形组成的格子,
问覆盖一个格子,两个格子,三个格子,四个格子的概率,要求圆心必须在矩形上
题解:
发现1,2,3,4组成的概率为1,然后发现3这种情况最难计算,所以计算出1,2,4,然后1去减就可以了。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std; const double PI=acos(-1.0),eps=1e-; int main()
{
int T,ca=;
for(scanf("%d",&T);T;T--)
{
double n,m,t,c,A[];
scanf("%lf%lf%lf%lf",&n,&m,&t,&c);
A[]=t*t*n*m;
A[]=(t-c)*(t-c)*n*m+(c*(t-c)+c*c/4.0)*+c*(t-c)*(n+m-);
A[]=*c*(t-c)*n*m-c*(t-c)*(n+m)+c*c*(n+m-);
A[]=PI*c*c/*(n-)*(m-);
A[]=A[]-A[]-A[]-A[];
printf("Case %d:\n",++ca);
for(int i=;i<=;i++)
printf("Probability of covering %d tile%s = %.4lf%%\n",i,(i==)?" ":"s",A[i]/A[]*100.0+eps);
printf("\n");
}
}
poj3440--Coin Toss(几何上的概率)的更多相关文章
- UVA 10328 - Coin Toss dp+大数
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- UVA 10328 Coin Toss
Coin Toss Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: ...
- POJ 3440 Coin Toss(概率)
题目链接 概率问题,像是概率论上学的均匀分布,是不是呢,忘了... 概率同面积有关系,我写的各种搓,然后此题格式十分变态,=前有的时候俩空格,有的时候一个空格.代码各种搓. #include < ...
- POJ 3440 Coin Toss(求概率)
题目链接 题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率. 思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次..... #include ...
- poj 3440 Coin Toss 概率问题
这题主要是推导数学公式!!! 将概率问题转化为圆心所在的面积! 代码如下: #include<iostream> #include<stdio.h> #include<a ...
- Coin Toss(uva 10328,动态规划递推,限制条件,至少转至多,高精度)
有n张牌,求出至少有k张牌连续是正面的排列的种数.(1=<k<=n<=100) Toss is an important part of any event. When everyt ...
- UVa 10328 - Coin Toss (递推)
题意:给你一个硬币,抛掷n次,问出现连续至少k个正面向上的情况有多少种. 原题中问出现连续至少k个H的情况,很难下手.我们可以试着将问题转化一下. 设dp[i][j]表示抛掷i个硬币出现连续至多j个H ...
- [USACO Hol10] 臭气弹 图上期望概率dp 高斯
记住一开始和后来的经过是两个事件因此概率可以大于一 #include<cstdio> #include<iostream> #include<cstdlib> #i ...
- 题解 UVA10328 【Coin Toss】
这道题目其实就是说有N张纸牌,问至少连续K张正面朝上的可能性是多少. 可以用递推做.首先我们将题目所求从 至少K张 转化为 总数 - 至多K张 (为什么要这样自己想) 设F[i][j]为前i个纸牌至多 ...
随机推荐
- Java编码格式
简介 编码问题一直困扰着开发人员,尤其在 Java 中更加明显,因为 Java 是跨平台语言,不同平台之间编码之间的切换较多.本文将向你详细介绍 Java 中编码问题出现的根本原因,你将了解到:Jav ...
- sed简单脚本练习
sed脚本的执行顺序可以简记为:Read,Execute,Print,Repeat(读取,执行,打印,重复)简称REPR 分析脚本的执行顺序: l 读取一行到模式空间(sed内部的一个临时缓存,用于存 ...
- java之数据处理,小数点保留位数
1.返回字符串类型,保留后两位: public static String getRate(Object d) { return String.format("%.2f", d); ...
- SpringBoot之旅第七篇-Docker
一.引言 记得上大三时,要给微机房电脑安装系统,除了原生的操作系统外,还要另外安装一些必要的开发软件,如果每台电脑都重新去安装的话工作量就很大了,这个时候就使用了windows镜像系统,我们将要安装的 ...
- node.js学习笔记(1)
一. 安装以及环境配置 安装路径 http://nodejs.cn/download/ 多种环境选择 环境变量的配置 Step1 先检查环境变量中的系统变量里面的path,查看是否加入了nod ...
- 微信小程序组件解读和分析:十、input输入框
input输入框组件说明: 本文介绍input 输入框的各种参数及特性. input输入框示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 01 02 03 04 0 ...
- Farseer.net轻量级ORM开源框架说明及链接索引
项目简介 基于.net framework 4 开发. 基于Lambda表达式快速上手的ORM框架. 参考Entity Framework的调用方式. 基于Database First模式. POCO ...
- Java中List集合的遍历
一.对List的遍历有三种方式 List<String> list = new ArrayList<String>(); list.add("testone" ...
- 如何用SQL语句在指定字段前面插入新的字段?
如何用SQL语句在指定字段前面插入新的字段? 2007-10-17 09:28:00| 分类: 笔记|举报|字号 订阅 create proc addcolumn @tablename va ...
- php更改wampserver的站点目录
我都wampserver安装在f盘 F:\wamp\bin\apache\Apache2.4.4\conf文件夹下的hhtpd.conf文件ctrl+f查找DocumentRoot,第二次的位置修改即 ...