题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=3980&mosmsg=Submission+received+with+ID+13299007

题解:看这篇博文:http://blog.csdn.net/tri_integral/article/details/9772243

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<queue>
#include<utility> #define MAXN 360050
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,t) for(int i=s; i<=t; i++)
#define show(x) { cerr<<">>>"<<#x<<" = "<<x<<endl; }
#define showtwo(x,y) { cerr<<">>>"<<#x<<"="<<x<<" "<<#y<<" = "<<y<<endl; }
using namespace std; int n,r;
double x[MAXN]; int dcmp(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
} int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
int test_count = ;
while(cin>>n>>r)
{
if(n== && r==) break;
REP(i,n) cin>>x[i];
sort(x,x+n);
x[n] = ; long long ans = (long long)n*(n-)*(n-)/;
REP(i,n)
{
long long dis;
if(dcmp(x[i]-) < )
dis = upper_bound(x,x+n,x[i]++eps)- x - i - ;
else
dis = n - i + upper_bound(x,x+n,x[i]-+eps) - x - ; ans -= dis*(dis-)/;
}
printf("Case %d: ",test_count++);
cout<<ans<<endl;
}
}

uva_12535 - Probability Through Experiments的更多相关文章

  1. Fuzzy Probability Theory---(3)Discrete Random Variables

    We start with the fuzzy binomial. Then we discuss the fuzzy Poisson probability mass function. Fuzzy ...

  2. Tensorflow word2vec+manage experiments

    Lecture note 5: word2vec + manage experiments Word2vec Most of you are probably already familiar wit ...

  3. 【BZOJ2318】Spoj4060 game with probability Problem 概率

    [BZOJ2318]Spoj4060 game with probability Problem Description Alice和Bob在玩一个游戏.有n个石子在这里,Alice和Bob轮流投掷硬 ...

  4. Fuzzy Probability Theory---(2)Computing Fuzzy Probabilities

    Let $X=\{x_1,x_2,...,x_n\}$ be a finite set and let $P$ be a probability function defined on all sub ...

  5. 基本概率分布Basic Concept of Probability Distributions 8: Normal Distribution

    PDF version PDF & CDF The probability density function is $$f(x; \mu, \sigma) = {1\over\sqrt{2\p ...

  6. 基本概率分布Basic Concept of Probability Distributions 7: Uniform Distribution

    PDF version PDF & CDF The probability density function of the uniform distribution is $$f(x; \al ...

  7. 基本概率分布Basic Concept of Probability Distributions 6: Exponential Distribution

    PDF version PDF & CDF The exponential probability density function (PDF) is $$f(x; \lambda) = \b ...

  8. 基本概率分布Basic Concept of Probability Distributions 5: Hypergemometric Distribution

    PDF version PMF Suppose that a sample of size $n$ is to be chosen randomly (without replacement) fro ...

  9. 基本概率分布Basic Concept of Probability Distributions 4: Negative Binomial Distribution

    PDF version PMF Suppose there is a sequence of independent Bernoulli trials, each trial having two p ...

随机推荐

  1. nodejs基础安装

    安装Nodejs需要从官网上下载一个最新的安装包,运行.我这里是win764位系统. 下载版本6.5.0 由于去外国的镜像上下载东西比较慢,淘宝为我们准备了国内的镜像.我们需要安装国内镜像的使用工具. ...

  2. iOS最新上线流程+续费 2015-7-20更新

    一.程序上线前准备 确认图标是否⻬全,应⽤的icon图标 在以前图⽚片直接命名 为icon就可以了,在xcode5以后,苹果加 ⼊入了images.xcasset这个⽂文件夹,所有的 图标全都在这⾥里 ...

  3. python 文件查找 glob

    glob模块是最简单的模块之一,内容非常少.用它可以查找符合特定规则的文件路径名.跟使用windows下的文件搜索差不多.查找文件只用到三个匹配符:"*", "?&quo ...

  4. python join字符连接函数的使用方法

    就是把一个list中所有的串按照你定义的分隔符连接起来,比如: >>> import string >>> >>> >>> li ...

  5. CSS 背景-CSS background

    这里有个很好的样式学习网站:http://www.divcss5.com/rumen/r125.shtml 一.Css background背景语法   -   TOP CSS背景基础知识 CSS 背 ...

  6. percona-xtrabackup安装及使用教程

    安装percona-xtrabackup依赖包(前提已安装mysql) yum -y install perl-CPAN perl-DBD-MySQL perl make gcc gcc-c++ pa ...

  7. http://www.itpub.net/thread-1778530-1-1.html

    http://www.itpub.net/thread-1778530-1-1.html

  8. js 中var that=this

    js中经常出现var that=this,为什么这么做? http://stackoverflow.com/questions/4886632/what-does-var-that-this-mean ...

  9. 【DataStructure In Python】Python模拟二叉树

    使用Python模拟二叉树的基本操作,感觉写起来很别扭.最近做编译的优化,觉得拓扑排序这种东西比较强多.近期刷ACM,发现STL不会用实在太伤了.决定花点儿时间学习一下STL.Boost其实也很强大. ...

  10. Outlook接收qq的邮件

    1.先去qq邮箱,设置,账户 开启pop3服务,假如之前开启过,最好关闭之后重新开启 最新版本的必须使用邮箱的独立密码才可以收取邮件 (否则就算你之前开通了,也无法用你的qq账号和密码收取邮件的) 2 ...