The Little Girl who Picks Mushrooms HDU
来源:互联网 发布:北京网络预约挂号平台 编辑:程序博客网 时间:2024/06/04 19:14
当n<=3是肯定可以带回去1024因为可以用另外一包跟n包凑成给仙女的 然后另外一包或两包是1024
当n=4时 两种情况 1.选已采集的两包蘑菇,跟待采集的1包凑成1024的整数倍,让剩下的最多
已存在3包能凑成整数倍,待采集的那一包跟已采集的凑成1024
N=5时判断有没有3包组成1024的整数倍即可。
但是n为4或5时有个很坑的地方就是可以给仙女0个。
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
int a[5];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
if(n<=3)cout<<"1024"<<endl;
else if(n==4)
{
//sort(a,a+4);
int mmax=-999999;
int sum=a[0]+a[1]+a[2]+a[3];
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
if(i!=j)
{
mmax=max(mmax,(sum-a[i]-a[j])%1024);
if((sum-a[i]-a[j])%1024==0&&(sum-a[i]-a[j])!=0)
mmax=1024;
}
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
for(int k=0;k<4;k++)
{
if((i!=j)&&(j!=k)&&(i!=k))
{
if((a[i]+a[j]+a[k])%1024==0)
{
mmax=1024;
}
}
}
}
}
if(mmax<0)mmax=0;
cout<<mmax<<endl;
}
else
{
//sort(a,a+5);
int sum=a[0]+a[1]+a[2]+a[3]+a[4];
int mmax=-999999;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
for(int k=0;k<5;k++)
{
if((i!=j)&&(j!=k)&&(i!=k))
{
if((a[i]+a[j]+a[k])%1024==0)
{
mmax=max(mmax,(sum-a[i]-a[j]-a[k])%1024);
if((sum-a[i]-a[j]-a[k])%1024==0&&(sum-a[i]-a[j]-a[k])!=0)
mmax=1024;
}
}
}
}
}
if(mmax<0)mmax=0;
cout<<mmax<<endl;
}
}
return 0;
}
- The Little Girl who Picks Mushrooms HDU
- The Little Girl who Picks Mushrooms(HDU
- The Little Girl who Picks Mushrooms HDU
- hdu 4422 The Little Girl who Picks Mushrooms
- hdu 4422The Little Girl who Picks Mushrooms
- hdu(4422)The Little Girl who Picks Mushrooms
- hdu 4422 The Little Girl who Picks Mushrooms
- Hdu 4422 The Little Girl who Picks Mushrooms
- HDU 4422 The Little Girl who Picks Mushrooms(模拟)
- hdu 4422——The Little Girl who Picks Mushrooms
- 【瞎搞】 HDU 4422 The Little Girl who Picks Mushrooms
- HDU 4422 The Little Girl who Picks Mushrooms(数学)
- HDU 4422 The Little Girl who Picks Mushrooms【水题】
- HDU 4422 The Little Girl Who Picks Mushrooms
- hdu 4422 The Little Girl who Picks Mushrooms(水题)
- HDU 4422 The Little Girl who Picks Mushrooms(模拟)
- The Little Girl who Picks Mushrooms
- HDUOJ4422 The Little Girl who Picks Mushrooms
- SpringMVC、Struts1和Struts2区别
- 数据结构知识点系列三
- 习题4.0
- 多目标跟踪竞赛结果摘要 Multiple Object Tracking Challenge 2017 Results
- Android Studio 开发过程中遇到错误以及解决方案
- The Little Girl who Picks Mushrooms HDU
- 2017-11-29
- 剑指offer——数值的整数次方
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query (线段树)
- 《忙里偷闲的悲伤》
- 集合CollectionUtils的操作方法
- 《弃子长安》第十一章 一路向西
- 输入某班学生成绩,求不及格人数
- Mongodb数据库(python)