首页 > 其他 > 详细

HDU 5364 5366

时间:2015-08-15 20:07:47      阅读:173      评论:0      收藏:0      [点我收藏+]

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
 

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
 

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;
}





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

HDU 5364 5366

原文:http://blog.csdn.net/sky_miange/article/details/47683943

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!