题目链接

概率问题,像是概率论上学的均匀分布,是不是呢,忘了。。。

概率同面积有关系,我写的各种搓,然后此题格式十分变态,=前有的时候俩空格,有的时候一个空格。代码各种搓。

 #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(概率)的更多相关文章

  1. poj 3440 Coin Toss 概率问题

    这题主要是推导数学公式!!! 将概率问题转化为圆心所在的面积! 代码如下: #include<iostream> #include<stdio.h> #include<a ...

  2. POJ 3440 Coin Toss(求概率)

    题目链接 题意 :把硬币往棋盘上扔,分别求出硬币占1,2,3,4个格子的时候的概率. 思路 : 求出公式输出,不过要注意输出格式,我还因为输入的时候用了int类型错了好几次..... #include ...

  3. UVA 10328 - Coin Toss dp+大数

    题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  4. UVA 10328 Coin Toss

    Coin Toss Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: ...

  5. poj 2096 Collecting Bugs - 概率与期望 - 动态规划

    Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...

  6. poj 3071 Football(概率dp)

    id=3071">http://poj.org/problem? id=3071 大致题意:有2^n个足球队分成n组打比赛.给出一个矩阵a[][],a[i][j]表示i队赢得j队的概率 ...

  7. POJ 3071 Football:概率dp

    题目链接:http://poj.org/problem?id=3071 题意: 给定n,有2^n支队伍参加足球赛. 给你所有的p[i][j],表示队伍i打败队伍j的概率. 淘汰赛制.第一轮(1,2)两 ...

  8. Coin Toss(uva 10328,动态规划递推,限制条件,至少转至多,高精度)

    有n张牌,求出至少有k张牌连续是正面的排列的种数.(1=<k<=n<=100) Toss is an important part of any event. When everyt ...

  9. 2017 ACM-ICPC 亚洲区(西安赛区)网络赛: B. Coin 【概率题】【数论】

    Bob has a not even coin(就是一个不均匀的硬币,朝上的概率不一定是1/2), every time he tosses the coin, the probability tha ...

随机推荐

  1. Tornaod框架

    Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像web.py 或者 Google 的 webapp,不过为了能有效 ...

  2. Convert Sorted List to Balanced BST

    Given a singly linked list where elements are sorted in ascending order, convert it to a height bala ...

  3. js:判断对象是否为空

    var list = []; var param = {}; ....... var hasProp = false; for (var prop in param){ hasProp = true; ...

  4. operator new3种情况详解

    [本文链接] http://www.cnblogs.com/hellogiser/p/operator-new.html [代码]  C++ Code  12345678910111213141516 ...

  5. Solr5.3.1整合IKAnalyzer

    由于solr5.3.1本身不支持中文分词,而msseg4j的分词效果不明显.因而采用IK进行分词,然而参考http://www.superwu.cn/2015/05/08/2134/在google上下 ...

  6. 【动态规划】The Triangle

    问题 E: [动态规划]The Triangle 时间限制: 1 Sec  内存限制: 128 MB提交: 24  解决: 24[提交][状态][讨论版] 题目描述 73 88 1 02 7 4 44 ...

  7. Gym 100851G Generators (vector+鸽笼原理)

    Problem G. Generators Input file: generators.in Output file: generators.outLittle Roman is studying li ...

  8. AJAX,JSON用户名校验

    效果 开发结构 1,src部分有两个包dao和servlet 1.1dao包下有两个数据库工具类文件 SqlHelper.java package org.guangsoft.dao; import ...

  9. MFC中挂起线程和恢复线程

    DWORD SuspendThread ( HANDLE hThread );   //挂起线程DWORD ResumeThread ( HANDLE hThread );   //恢复线程 比如说我 ...

  10. 比较两个目录中的文件 diff -rq

    [root@bass test]# mkdir A B [root@bass test]# tree A A └── lin 0 directories, 1 file [root@bass test ...