HDU 5364 5366

Distribution money

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 511    Accepted Submission(s): 291

Problem Description

AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man‘s money is more than the sum of all others‘.He shoule be punished.Each one
who get a part of money would write down his ID on that part.

Input

There are multiply cases.

For each case,there is a single integer n(1<=n<=1000) in first line.

In second line,there are n integer a1,a2...an(0<=ai<10000)ai is the the ith man‘s ID.

Output

Output ID of the man who should be punished.

If nobody should be punished,output -1.

Sample Input

3
1 1 2
4
2 1 4 3

Sample Output

1
-1

Source

BestCoder Round #50 (div.2)

Recommend

hujie   |   We have carefully selected several similar problems for you:  5390 5389 5388 5387 5386

找出现数字大于2/n的。

#include <cstdio>
#include <cmath>
#include <queue>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int a[10005];
        int i,x;
        int ans;
        memset(a,0,sizeof(a));
        for(i=0; i<n; i++)
        {
            cin>>x;
            a[x]++;
        }
        ans=n/2;
        int flag=0;
        for(i=0; i<=10000; i++)
        {
            if(a[i]>ans)
            {
                flag=1;
                cout<<i<<endl;
                break;
            }
        }
        if(!flag)
            cout<<-1<<endl;
    }
    return 0;
}

The mook jong

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 585    Accepted Submission(s): 419

Problem Description

![](../../data/images/C613-1001-1.jpg)

ZJiaQ want to become a strong man, so he decided to play the mook jong。ZJiaQ want to put some mook jongs in his backyard. His backyard consist of n bricks that is 1*1,so it is 1*n。ZJiaQ want to put a mook jong in a brick. because of the hands of the mook jong,
the distance of two mook jongs should be equal or more than 2 bricks. Now ZJiaQ want to know how many ways can ZJiaQ put mook jongs legally(at least one mook jong).

Input

There ar multiply cases. For each case, there is a single integer n( 1 < = n < = 60)

Output

Print the ways in a single line for each case.

Sample Input

1
2
3
4
5
6

Sample Output

1
2
3
5
8
12

Source

BestCoder Round #50 (div.2)

Recommend

hujie   |   We have carefully selected several similar problems for you:  5390 5389 5388 5387 5386

水dp。

#include <cstdio>
#include <cmath>
#include <queue>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
ll m[111];
ll solve(int i)
{
    if (m[i] != 0)
        return m[i];
    m[i] = solve(i-1) + solve(i-3) + 1;
    return m[i];
}

int main()
{
    int n;
    m[0] = 0;
    m[1] = 1;
    m[2] = 2;
    m[3] = 3;
    while (cin >> n)
        cout << solve(n) << endl;
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-03 15:29:24

HDU 5364 5366的相关文章

HDU 5364 Distribution money

Problem Description AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man's money is more than the sum of all others'.He shoule be punished.Each o

hdu 5364

#include <iostream>#include <stdio.h>#include<math.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std; int main(){ int n,s[1005]; int u,flag,min; while(cin>>n) { min=u=0; memset(s,0,10

hdu 5364 (bc#50 1001) Distribution money

Distribution money Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 276    Accepted Submission(s): 163 Problem Description AFA want to distribution her money to somebody.She divide her money into

HDU 5364-Distribution money(水题)

题目地址:HDU 5364 中文题意: 问题描述 地主小花难得当一回好人,这次她准备给长工们发津贴.有些长工会偷偷地在领完津贴后又排回队伍里去领津贴.不过小花对此表示无所谓,因为她发的是固定数额的津贴.但是如果有人领到的津贴超过其他所有人的总和的话,小花为了显示自己的公正,会去惩罚他.现已知每个来领津贴的人会登记下自己的工号. 输入描述 输入有多组数据,每组第一行为一个n(1 < = n < = 1000),表示有多少津贴被领,第二行n个数字a1,a2-an,表示n个来领津贴的人的工号(0 &

JS中URL编码参数(UrlEncode)

网上有很多文字作品写涉及在JS中呈现类似UrlEncode功能时都是自定义参数来呈现,其实JS中本身就有那样的参数.参数parameter由于用类似URL的形式传过去 , 所以别直接就那样赋值以下是对变量值的URL编码总结 : 意见用encodeURIComponent() , GET 和POST方法都能够发送过去Java编程script中存在几种对URL字符串停止编码的窍门:escape(),encodeURI(),以及encodeURIComponent().这几种编码所起的功能各不相同.e

JS base64 加密和 后台 base64解密(防止中文乱码)

直接上代码 1,js(2个文件,网上找的)  不要觉的长,直接复制下来就OK //UnicodeAnsi.js文件 //把Unicode转成Ansi和把Ansi转换成Unicode function UnicodeChr() { return '00A4,00A7,00A8,00B0,00B1,00B7,00D7,00E0,00E1,00E8,00E9,00EA,00EC,00ED,00F2,00F3,00F7,00F9,00FA,00FC,0101,0113,011B,012B,014D,01

Html5模拟通讯录人员排序(sen.js)

// JavaScript Document var PY_Json_Str = ""; var PY_Str_1 = ""; var PY_Str_2 = "";  var PY_Str_3 = "";  var PY_Str_4 = ""; var PY_Str_5 = ""; var PY_Str_6 = "";  var PY_Str_7 = "&q

MFC简单的橡皮筋程序

网上有很多文字作品写涉及在JS中呈现类似UrlEncode功能时都是自定义参数来呈现,其实JS中本身就有那样的参数.参数parameter由于用类似URL的形式传过去 , 所以别直接就那样赋值以下是对变量值的URL编码总结 : 意见用encodeURIComponent() , GET 和POST方法都能够发送过去Java编程script中存在几种对URL字符串停止编码的窍门:escape(),encodeURI(),以及encodeURIComponent().这几种编码所起的功能各不相同.e

将able导出为excel格式文件

html: <table cellpadding="0" cellspacing="0" class="data_table" id="data_table"> <tr> <th>日期</th> <th>星期</th> <th>渠道</th> <th>服务区</th> <th>总用户</th