题目链接: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. asp.net mvc 事务处理:Transactions

    1.在控制器里引用using System.Transactions; 2.在你需要事务回滚的地方外面套一层using (TransactionScope sc = new TransactionSc ...

  2. Javascript 5种方法实现过滤删除前后所有空格

    第一种:循环检查替换 //供使用者调用 function trim(s){ return trimRight(trimLeft(s)); } //去掉左边的空白 function trimLeft(s ...

  3. 西门子plc串口通讯方式

    西门子plc串口通讯的三种方式 时间:2015-10-25 14:31:55编辑:电工栏目:西门子plc 导读:西门子plc串口通讯的三种方式,分为RS485 串口通信.PPI 通信.MPI 通信,自 ...

  4. .bat批处理脚本让cmd命令行提示符cd到工作目录 (转)

    打开cmd,检查命令行提示符所在的默认位置(目录),进入该目录用notepad++创建一个文件,输入 @echo offrem 这个符号表示该行是注释.rem 进入f盘,需要先切换盘符,成功后才能进入 ...

  5. Dynamic Programming (DP) 问题总结

    所有的 DP 问题都可以简单得用 Recursion 的方式实现.这通常是最容易想到的思路. 问题是这种实现不够 efficient,存在 subproblem 被重复计算的情况.有两种解决这个问题的 ...

  6. 南方数据企业0day

    漏洞影响版本 v10.0 v11.0 关键字:inurl:”HomeMarket.asp” 默认后台:/admin 直接爆用户密码: http://www.xxx.com/NewsType.asp?S ...

  7. 李洪强漫谈iOS开发[C语言-023]-取余数运算符

  8. asp.net控件(1)Repeater

    1. 通过Repeater和数据源创建表格 <AlternatingItemTemplate>属性可以控制单元格交替显示不同的背景颜色 <table width=" sty ...

  9. ANDROID_MARS学习笔记_S02_011_ANIMATION_LayoutAnimationController

    一.简介 二.代码1.xml(1)activity_main.xml <ListView android:id="@id/android:list" android:layo ...

  10. More on 1Password’s Components

    Stefan van As of 1Password fame sent me a more exhaustive list of the libraries and tools used in 1P ...