CF802D
2 seconds
256 megabytes
standard input
standard output
Heidi is a statistician to the core, and she likes to study the evolution of marmot populations in each of V(1 ≤ V ≤ 100) villages! So it comes that every spring, when Heidi sees the first snowdrops sprout in the meadows around her barn, she impatiently dons her snowshoes and sets out to the Alps, to welcome her friends the marmots to a new season of thrilling adventures.
Arriving in a village, Heidi asks each and every marmot she comes across for the number of inhabitants of that village. This year, the marmots decide to play an April Fools' joke on Heidi. Instead of consistently providing the exact number of inhabitants P (10 ≤ P ≤ 1000) of the village, they respond with a random non-negative integer k, drawn from one of two types of probability distributions:
- Poisson (d'avril) distribution: the probability of getting an answer k is
for k = 0, 1, 2, 3, ..., - Uniform distribution: the probability of getting an answer k is
for k = 0, 1, 2, ..., 2P.
Heidi collects exactly 250 answers per village. Every village follows either the Poisson or the uniform distribution. Heidi cannot tell marmots apart, so she may query some marmots several times, and each time the marmot will answer with a new number drawn from the village's distribution.
Can you help Heidi to find out whether a village follows a Poisson or a uniform distribution?
The first line of input will contain the number of villages V (1 ≤ V ≤ 100). The following V lines each describe one village. The description of each village consists of 250 space-separated integers k, drawn from one of the above distributions.
Output one line per village, in the same order as provided in the input. The village's line shall state poisson if the village's distribution is of the Poisson type, and uniform if the answer came from a uniform distribution.
2
92 100 99 109 93 105 103 106 101 99 ... (input is truncated)
28 180 147 53 84 80 180 85 8 16 ... (input is truncated)
poisson
uniform
The full example input is visually represented below, along with the probability distribution function it was drawn from (the y-axis is labeled by its values multiplied by 250).

一道很神奇的水题,泊松分布和方差有关,所以我先找到平均值
他和正态分布是想似的,怎么转换为3西格玛原则呢,就是找到所在位置呗,一半和三分之一还是比较好的,然后这里面的值应该要有比3西格玛中间的数多,随便输了个0.75,蜜汁AC
#include <bits/stdc++.h>
using namespace std;
int main(){
int T;
scanf("%d",&T);
while(T--){
int a[];
int s=;
for(int i=;i<;i++){
scanf("%d",&a[i]);
s+=a[i];
}
double ave=s/250.0;
int cnt=;
for(int i=;i<;i++){
if(fabs(a[i]-ave)<=ave/)
cnt++;
}
if(cnt>*0.75)
puts("poisson");
else
puts("uniform");
}
return ;}
CF802D的更多相关文章
随机推荐
- Java-String字符串相关
字符串String: 封装char[] 字符数组,不可变(因为在底层代码中,值用final关键字修饰) 字符串的字面值: 如果第一次用到一个字符串字面值,会在内存中"字符串常量池" ...
- [转]Fedora 下安装NVIDIA显卡驱动(使用后无法进入图形界面)
http://www.linuxidc.com/Linux/2014-04/100689.htm rpmfusion安装法: 相对于ATi,在Linux下安装NVIDIA就简单得多.只需要一个命令即可 ...
- Emacs Org-mode中英文字体设置
Emacs Org-mode中英文字体设置 Table of Contents 1. 缺省字体存在的问题 2. 解决方法 2.1. 环境说明 2.2. 思路和方法 2.3. emacs设置代码 2.4 ...
- jQuery和AJAX基础
jQuery和AJAX基础 jQuery 基础: 1.jQuery 选择器: 元素选择器:$("p"): #id 选择器:$("#test"): .class ...
- 记AccessibilityService使用(转)
转自 :http://www.jianshu.com/p/ba298b8d5a6e 一.AccessibilityService的使用 首先先写一个类去继承AccessibilityService p ...
- 深入浅出Android动态加载jar包技术
在实际项目中,由于某些业务频繁变更而导致频繁升级客户端的弊病会造成较差的用户体验,而这也恰是Web App的优势,于是便衍生了一种思路,将核心的易于变更的业务封装在jar包里然后通过网络下载下来,再由 ...
- C++遍历文件及文件夹代码
可以遍历目录包含的文件及文件夹 #include <string> #include <vector> #include <io.h> using std::vec ...
- 最近在准备面试,总结了几个java中面向对象的几个问题,问题本事还不够全面,要想知道还是要自己去找,但是在面试上应该是没多大问题了
Overload(重载)与Override(重写)的区别 重载:发生在一个类中,方法名称相同,参数列表不同,方法体不同(看对象类型) 重写:发生在父类中,方法名称相同,参数列表相同,方法体不同(看引用 ...
- python打飞机pro版
# -*- coding: utf-8 -*- import pygame from sys import exit import random pygame.init() screen = pyga ...
- 使用vue做移动端瀑布流分页
讲到瀑布流分页有一个方法一定是要用到的 pullToRefresh() 这个也没什么好解释的,想了解的可以去百度一下 下面上代码 <div id="main" class=& ...