题目链接: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. EntityFramework-DBFirst-重新生成后写的验证消失(解决办法)

    1.这是EF生成的类: namespace PMS.DataProvider.EntityFramework { using System; using System.Collections.Gene ...

  2. 软件测试 -- alpha测试和beta测试的区别

    alpha测试是在用户组织模拟软件系统的运行环境下的一种验收测试,由用户或第三方测试公司进行的测试,模拟各类用户行为对即将面市的软件产品进行测试,试图发现并修改错误. Beta测试是用户公司组织各方面 ...

  3. 如何获得iphone设备的剩余空间

    在手机终端开发的时候,我们需要关注手机剩余空间,因为手机不像电脑一样空间宽裕,当设备空间比较少得时候需要释放空间. 用法:先引入头文件 #include <sys/param.h> #in ...

  4. Java 代码优化过程的实例介绍

    衡量程序的标准 衡量一个程序是否优质,可以从多个角度进行分析.其中,最常见的衡量标准是程序的时间复杂度.空间复杂度,以及代码的可读性.可扩展性.针对程序的时间复杂度和空间复杂度,想要优化程序代码,需要 ...

  5. DIY RazorEngine 的程序集生成方式

    最近遇到一个项目,要使用RazorEngine做模板引擎,然后完成简易的CMS功能,以减轻重复的CDRU操作,同时复用管理后台.没错,使用的正是GIT HUB上的开源项目:https://github ...

  6. BZOJ 1709: [Usaco2007 Oct]Super Paintball超级弹珠

    Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 1 ...

  7. OTG

    OTG技术就是在没有Host的情况下,实现设备间的数据传送.例如数码相机直接连接到打印机上,通过OTG技术,连接两台设备间的USB口,将拍出的相片立即打印出来:也可以将数码照相机中的数据,通过OTG发 ...

  8. WCF - IIS Hosting

    WCF - IIS Hosting Hosting a WCF service in IIS (Internet Information Services) is a step-by-step pro ...

  9. GridView導出Excel 解決亂碼問題

    Response.Clear(); Response.Charset = "gb2312"; Response.Buffer = true; Response.AddHeader( ...

  10. cmd for 用法

    1:for命令及变量 基本格式: FOR /参数 %variable IN (set) DO command [command_parameters] %variable:指定一个单一字母可替换的参数 ...