4422

小于等于3 的时候就是1024 4的时候 讨论 5的时候讨论 注意重量为0的情况

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
int a[];
int n;
int main()
{
int i,j,g;
while(scanf("%d",&n)!=EOF)
{
int sum=;
for(i = ; i <= n ; i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
if(n<=)
{
printf("1024\n");
continue;
}
else
{
if(n==)
{
int flag = ;
for(i = ; i <= n ; i++)
{
int s1 = ;
for(j = ; j <= n ; j++)
if(j!=i)
s1+=a[j];
if(s1%==)
{
flag = ;
break;
}
}
int maxz=;
for(i = ; i <= n ; i++)
for(j = ; j <= n ; j++)
{
if(j!=i)
{
if(a[i]+a[j])
{
if((a[i]+a[j])%==)
maxz = ;
else
maxz = max(maxz,(a[i]+a[j])%);
}
}
}
if(flag)
printf("1024\n");
else
printf("%d\n",maxz);
}
else
{
int maxz = ;
for(g = ; g <= n ; g++)
{
for(i = ; i <= n ; i++)
{
if(i==g) continue;
int s1 = ;
for(j = ; j <= n ; j++)
if(j!=i&&j!=g)
s1+=a[j];
if(s1%==)
{
if((sum-s1)&&(sum-s1)%==)
maxz = ;
else
maxz = max(maxz,(sum-s1)%);
}
}
}
printf("%d\n",maxz);
}
}
}
return ;
}

hdu4422The Little Girl who Picks Mushrooms的更多相关文章

  1. ZOJ - 3657-The Little Girl who Picks Mushrooms

    /*ZOJ Problem Set - 3657 The Little Girl who Picks Mushrooms Time Limit: 2 Seconds Memory Limit: 327 ...

  2. HDU 4422 The Little Girl who Picks Mushrooms ( 模拟)

    Problem Description It's yet another festival season in Gensokyo. Little girl Alice planned to pick ...

  3. HDU 4422 The Little Girl who Picks Mushrooms(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=4422 Problem Description It's yet another festival s ...

  4. 状态压缩 UVALive 6068 The Little Girl who Picks Mushrooms (12长春C)

    题目传送门 题意:采蘑菇.现在采了n座山,共5座山,最后要求有三个篮子的蘑菇量是1024的整数倍,丢掉后一直减1024直到不超过1024 分析:n <= 3时直接1024,否则状压枚举哪三个篮子 ...

  5. HDU 4422 The Little Girl who Picks Mushrooms

    题意:一共有5座山,已知小女孩在n座山采了n篮蘑菇,如果n小于5则在其他的山里采了任意重量的蘑菇,给出每篮蘑菇的重量,她回去的时候会遇到仨女巫要她交出三篮蘑菇的重量和恰好为1024的倍数,否则就把她的 ...

  6. HDU 4422 The Little Girl who Picks Mushrooms(简单题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4422 题目大意:小姑娘背着5个包去山上采蘑菇,每座山上只能用一个背包采集.三个小精灵会要她3个背包,其 ...

  7. Random Forest Classification of Mushrooms

    There is a plethora of classification algorithms available to people who have a bit of coding experi ...

  8. Comparing the contribution of NBA draft picks(转)

    When it comes to the NBA draft, experts tend to argue about a number of things: at which position wi ...

  9. hdu 6406 Taotao Picks Apples 线段树 单点更新

    Taotao Picks Apples Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Ot ...

随机推荐

  1. RVA与Offset的换算函数

    function RVAToFileOffset(FileName:string; RVA: Cardinal): Cardinal; var   MemPE: TFileStream;   PEDo ...

  2. JavaScript之setcookie()讲解

    function setcookie(name,value){          var Days = 30;          var exp  = new Date();          exp ...

  3. css内边距与外边距的区别

    你真的了解margin吗?你知道margin有什么特性吗?你知道什么是垂直外边距合并?margin在块元素.内联元素中的区别?什么时候该用 padding而不是margin?你知道负margin吗?你 ...

  4. javascript实现数据结构与算法系列:栈 -- 顺序存储表示和链式表示及示例

    栈(Stack)是限定仅在表尾进行插入或删除操作的线性表.表尾为栈顶(top),表头为栈底(bottom),不含元素的空表为空栈. 栈又称为后进先出(last in first out)的线性表. 堆 ...

  5. 使用PHP_UML生成代码的UML图

    在读别人代码的时候, 在没有详细文档的时候, 如何快速的看清整个代码的结构(类结构), 就成为了一个现实的问题. 今天我就介绍一种, 自动生成UML图的方法. 假设, 我有一个项目文件夹:laruen ...

  6. c# 获取mac地址的2种方法

    和大家分享下,互相学习一下吧.第一个获取方法好像获取不到mac地址,我用了第二种方法可以获取到.希望知道的可以说下为什么. 1,首先要添加引用:using System.Management; 2,代 ...

  7. tomcat 多开设置 需要需改的3个端口

    启动多tomcat需要需改的3个端口 我所用Tomcat服务器都为zip版,非安装版.以两个为例: 安装第二个Tomcat完成后,到安装目录下的conf子目录中打开server.xml文件,查找以下三 ...

  8. ios图片拉伸两种方法

    UIImage *image = [UIImage imageNamed:@"qq"]; 第一种: // 左端盖宽度 NSInteger leftCapWidth = image. ...

  9. POJ 1978

    #include <iostream> #define MAXN 55 using namespace std; int _m[MAXN]; int tem[MAXN]; void cop ...

  10. java EE 5 Libraries 删掉后怎么重新导入

    (1)Add Library   中  MyEclipse Libraries (2)输入 java  即可找到 问题解决.