POJ 3440 Coin Toss(概率)
概率问题,像是概率论上学的均匀分布,是不是呢,忘了。。。
概率同面积有关系,我写的各种搓,然后此题格式十分变态,=前有的时候俩空格,有的时候一个空格。代码各种搓。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define PI 3.141592653
#define eps 1e-9
int main()
{
int t,cas = ;
double n,m,d,r,S;
double t11,t12,t13,t14,t21,t22,t23,t24,t31,t32,t33,t34;
double a1,a2,a3,a4;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf",&n,&m,&d,&r);
S = n*m*d*d;
t11 = (d-r/)*(d-r/);
t12 = *(d-r/)*r/;
t13 = 0.25*PI*(r/)*(r/);
t14 = (r/)*(r/) - t13;
t21 = (d-r/)*(d-r);
t22 = (d-r/)*r + (d-r)*r/;
t23 = 0.5*PI*(r/)*(r/);
t24 = *(r/)*(r/) - t23;
t31 = (d-r)*(d-r);
t32 = *(d-r)*r/;
t33 = PI*(r/)*(r/);
t34 = r*r - t33;
if(n == &&m == )
{
a1 = S;
a2 = ;
a3 = ;
a4 = ;
}
else if(n == )
{
a1 = *(d-r/)*d + (m-)*(d-r)*d;
a2 = S - a1;
a3 = ;
a4 = ;
}
else if(m == )
{
a1 = *(d-r/)*d + (n-)*(d-r)*d;
a2 = S - a1;
a3 = ;
a4 = ;
}
else
{
a1 = *t11 + *(n-+m-)*t21 + (n-)*(m-)*t31;
a2 = *t12 + *(n-+m-)*t22 + (n-)*(m-)*t32;
a3 = *t13 + *(n-+m-)*t23 + (n-)*(m-)*t33;
a4 = *t14 + *(n-+m-)*t24 + (n-)*(m-)*t34;
}
printf("Case %d:\n",cas++);
printf("Probability of covering 1 tile = %.4f%%\n",a1*/S);
printf("Probability of covering 2 tiles = %.4f%%\n",a2*/S);
printf("Probability of covering 3 tiles = %.4f%%\n",a4*/S);
printf("Probability of covering 4 tiles = %.4f%%\n",a3*/S);
printf("\n");
}
return ;
}
POJ 3440 Coin Toss(概率)的更多相关文章
- poj 3440 Coin Toss 概率问题
这题主要是推导数学公式!!! 将概率问题转化为圆心所在的面积! 代码如下: #include<iostream> #include<stdio.h> #include<a ...
- POJ 3440 Coin Toss(求概率)
题目链接 题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率. 思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次..... #include ...
- 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 2096 Collecting Bugs - 概率与期望 - 动态规划
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- poj 3071 Football(概率dp)
id=3071">http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率 ...
- POJ 3071 Football:概率dp
题目链接:http://poj.org/problem?id=3071 题意: 给定n,有2^n支队伍参加足球赛. 给你所有的p[i][j],表示队伍i打败队伍j的概率. 淘汰赛制.第一轮(1,2)两 ...
- Coin Toss(uva 10328,动态规划递推,限制条件,至少转至多,高精度)
有n张牌,求出至少有k张牌连续是正面的排列的种数.(1=<k<=n<=100) Toss is an important part of any event. When everyt ...
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛: B. Coin 【概率题】【数论】
Bob has a not even coin(就是一个不均匀的硬币,朝上的概率不一定是1/2), every time he tosses the coin, the probability tha ...
随机推荐
- grep与egrep
当只有一个匹配条件时:egrep pattern file等价于grep -E pattern file 例如: 当多个匹配条件时,只能用egrep -e pattern1 -e pattern2 - ...
- coco2dx实现翻拍效果
昨天吃饭看见同事演示他做的翻牌效果,感觉不错,我心血来潮也来搞个,很简单直接上代码. class FlipCard : public CCNode { public: CREATE_FUNC(Flip ...
- ARGB32 to YUV12 利用 SDL1.2 SDL_ttf 在视频表面输出文本
提示:ARGB alpha通道的A + 原YUV表面的y0 + 要写进去的y1 = 计算出新的y2. 计算公式为 ( y1 * a + y0 * ( 255 - a ) ) / 255 void rg ...
- codeforces 476B.Dreamoon and WiFi 解题报告
题目链接:http://codeforces.com/problemset/problem/476/B 题目意思:给出两个字符串str1, str2,其中,str1 只由 '+' 和 '-' 组成,而 ...
- Ubuntu 13.04安装搜狗输入法
Ubuntu 13.04安装搜狗输入法 [日期:2013-07-08] 来源:Linux公社 作者:LinuxIDC.com [字体:大 中 小] 目标:在Ubuntu 13.04以及基于U ...
- Linux配置SSH公钥认证与Jenkins远程登录进行自动发布
公钥认证,是使用一对加密字符串,一个称为公钥(public key), 任何人都可以看到其内容,用于加密:另一个称为密钥(private key),只有拥有者才能看到,用于解密. 在使用jenkins ...
- gitlab web登入密码忘记以后可以用如下方式修改密码
➜ ~ gitlab-rails console production Loading production environment (Rails ) irb(main)::> ➜ ~ gitl ...
- ctrl + z fg bg
[root@bass ~]# jobs [1]+ Stopped vncviewer 192.168.1.17:5904 [root@bass ~]# #ctrl + z [root@bass ~]# ...
- WPF中的常用类汇总:
1.FrameworkElement: WPF中大部分的控件都可以转化成FrameworkElement,利用FrameworkElement属性获取相应的值: 2.WPF获取当前工作区域的宽度和高度 ...
- Windows 10 上强制Visual Studio以管理员身份运行
Windows 10 的一个既安全又蛋疼之处是UAC的行为被改变了.以往在Windows 7中,只要关闭了UAC,自己的帐号又是本机管理员组的,任何程序都会以管理员身份启动.然而,在Windows 8 ...