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. Stacked injection--堆叠注入--堆查询注入

    Stacked injection--堆叠注入--堆查询注入 原文地址;http://www.sqlinjection.net/stacked-queries/   本篇属于集合原作者的思路和个人想法 ...

  2. delphi中locate方法

    TDataSet控件以及它的继承控件,例如TSimpleDataSet/TClientDataSet等都可以使用Locate方法在结果数据集中查寻数据.程序首先必须使用SQL命令从后端数据库中取得数据 ...

  3. codeforces 425A Sereja and Swaps(模拟,vector,枚举区间)

    题目 这要学习的是如何枚举区间,vector的基本使用(存入,取出,排序等),这题的思路来自: http://www.tuicool.com/articles/fAveE3 //vector 可以用s ...

  4. iOS文件操作

      ];                   NSString *plistPath = [filePath stringByAppendingPathComponent:@"collect ...

  5. 广播接收者BroadcastReceiver

    BroadcastReceiver与activity,service有完整的生命周期不同,BroadcastReceiver本质上是一系统级别的监听器,专门负责监听各程序发出的broadcast.与程 ...

  6. listview优化 汇总

    1,listview加载性能优化ViewHolder 转自: http://blog.csdn.net/jacman/article/details/7087995 在android开发中Listvi ...

  7. [网页设计]Ajax、Comet与Websocket--转

    从http协议说起 1996年IETF  HTTP工作组发布了HTTP协议的1.0版本 ,到现在普遍使用的版本1.1,HTTP协议经历了17 年的发展.这种分布式.无状态.基于TCP的请求/响应式.在 ...

  8. Java:Comparator接口

    public interface Comparator<T> 接口里面的方法 int compare(T o1, T o2) o1 > o2 返回 1 o1 = o2 返回 0 o1 ...

  9. web.xml文件中加载顺序的优先级

    在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰. 首先可以肯定的是 ...

  10. libevent功能使用简介

    http://blog.csdn.net/happyanger6/article/details/7272324 1. 介绍 libevent是一个用来开发可扩展的网络服务器的事件通知函数库.当一个文 ...