HDU 4981 Goffi and Median(水)

HDU 4981 Goffi and Median

思路:排序就可以得到中间数,然后总和和中间数*n比较一下即可

代码:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 1005;

int n, a[N], sum;

int main() {
    while (~scanf("%d", &n)) {
	sum = 0;
	for (int i = 1; i <= n; i++) {
	    scanf("%d", &a[i]);
	    sum += a[i];
	}
	sort(a + 1, a + n + 1);
	if (a[(n + 1) / 2] * n > sum) printf("YES\n");
	else printf("NO\n");
    }
    return 0;
}
时间: 2024-08-10 17:18:18

HDU 4981 Goffi and Median(水)的相关文章

[BestCoder Round #6] hdu 4981 Goffi and Median (水题)

Goffi and Median Problem Description A median in a sequence with the length of n is an element which occupies position number ?n+12? after we sort the elements in the non-decreasing order (the elements are numbered starting with 1). A median of an ar

HDU 4981 Goffi and Median

题解:排序取中位数,然后与平均数比较即可. #include <cstdio> #include <algorithm> using namespace std; double a[1005],ave,med,sum; int n; int main(){ while(~scanf("%d",&n)){ sum=0; for(int i=1;i<=n;i++){scanf("%lf",&a[i]);sum+=a[i];}

HDU 4981

超级水的一道题.上题目 Problem Description A median in a sequence with the length of n is an element which occupies position number ?n+12? after we sort the elements in the non-decreasing order (the elements are numbered starting with 1). A median of an array (

HDU 4982 Goffi and Squary Partition(推理)

HDU 4982 Goffi and Squary Partition 思路:直接从完全平方数往下找,然后判断能否构造出该完全平方数,如果可以就是yes,如果都不行就是no,注意构造时候的判断,由于枚举一个完全平方数,剩下数字为kk,构造的时候要保证数字不重复 代码: #include <cstdio> #include <cstring> #include <cmath> int n, k; bool judge(int num) { int yu = num * n

HDU 4983 Goffi and GCD(数论)

HDU 4983 Goffi and GCD 思路:数论题,如果k为2和n为1,那么只可能1种,其他的k > 2就是0种,那么其实只要考虑k = 1的情况了,k = 1的时候,枚举n的因子,然后等于求该因子满足的个数,那么gcd(x, n) = 该因子的个数为phi(n / 该因子),然后再利用乘法原理计算即可 代码: #include <cstdio> #include <cstring> #include <cmath> typedef long long l

hdu 1251 统计难题 (map水过)

# include <stdio.h> # include <algorithm> # include <string.h> # include <map> # include <iostream> using namespace std; int main() { char a; string x; map<string,int>q; while(true) { scanf("%c",&a); if(a=

HDU 4893 Wow! Such Sequence! 水线段树

思路: 线段树走起.. 写完这题就退役T^T 单点更新的时候直接找到这个点的最近fib,然后维护当前和 和 fib的和 #include<stdio.h> #include<string.h> #include<iostream> #include<math.h> #include<algorithm> #include<queue> #include<map> #include<set> #include&l

hdu 1999 不可摸数 水题。

不可摸数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7966    Accepted Submission(s): 2024 Problem Description s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何数m,s(m)都不等于n,则称n为不可摸数. Input 包

hdu 4983 Goffi and GCD(数论)

题目链接:hdu 4983 Goffi and GCD 题目大意:求有多少对元组满足题目中的公式. 解题思路: n = 1或者k=2时:答案为1 k > 2时:答案为0(n≠1) k = 1时:需要计算,枚举n的因子,令因子k=gcd(n?a,n, 那么另一边的gcd(n?b,n)=nk才能满足相乘等n,满足k=gcd(n?a,n)的a的个数即为?(n/s),欧拉有o(n ̄ ̄√的算法 #include <cstdio> #include <cstring> #include