您的位置:首页 > 其它

HDU 5364 5366

2015-08-15 17:58 253 查看

Distribution money

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

Total Submission(s): 511    Accepted Submission(s): 291
[/b]

[align=left]Problem Description[/align]
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.

 

[align=left]Input[/align]
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.

 

[align=left]Output[/align]
Output ID of the man who should be punished.

If nobody should be punished,output -1.

 

[align=left]Sample Input[/align]

3
1 1 2
4
2 1 4 3

 

[align=left]Sample Output[/align]

1
-1

 

[align=left]Source[/align]
BestCoder Round #50 (div.2)

 

[align=left]Recommend[/align]
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

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

Total Submission(s): 585    Accepted Submission(s): 419
[/b]

[align=left]Problem Description[/align]
![](../../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).

 

[align=left]Input[/align]
There ar multiply cases. For each case, there is a single integer n( 1 < = n < = 60)

 

[align=left]Output[/align]
Print the ways in a single line for each case.

 

[align=left]Sample Input[/align]

1
2
3
4
5
6

 

[align=left]Sample Output[/align]

1
2
3
5
8
12

 

[align=left]Source[/align]
BestCoder Round #50 (div.2)

 

[align=left]Recommend[/align]
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;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM算法