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. 关于gzip压缩

    关于gzip压缩 http://httpd.apache.org/docs/2.0/mod/mod_deflate.html http://www.phpchina.com/resource/manu ...

  2. Sqli-labs less 44

    Less-44 本关是基于盲注的,这里盲注主要是要没有报错信息,所以要采用盲注.这关与42关的区别就在于没有报错信息,同时,我们使用同样方式的payload: 登录 username:admin Pa ...

  3. FM算法

    1.FM背景 在计算广告中,CTR预估(click-through rate)是非常重要的一个环节,因为DSP后面的出价要依赖于CTR预估的结果.在前面的相关博文中,我们已经提到了CTR中相关特征工程 ...

  4. Codeforces 414C Mashmokh and Reverse Operation

    题意:给你2^n个数,每次操作将其分成2^k份,对于每一份内部的数进行翻转,每次操作完后输出操作后的2^n个数的逆序数. 解法:2^n个数,可以联想到建立一棵二叉树的东西,比如  2,1,4,3就可以 ...

  5. System.getProperty()参数

    java.version Java 运行时环境版本 java.vendor Java 运行时环境供应商 java.vendor.url Java 供应商的 URL java.home Java 安装目 ...

  6. 机器学习之单变量线性回归(Linear Regression with One Variable)

    1. 模型表达(Model Representation) 我们的第一个学习算法是线性回归算法,让我们通过一个例子来开始.这个例子用来预测住房价格,我们使用一个数据集,该数据集包含俄勒冈州波特兰市的住 ...

  7. 安卓开发利用外部jar包时ClassNotFound的错误

    今天调试一个小程序,一直没有进入 MainActivity 中的onCreate方法,因为没有看见提前设置好的log,然后仔细观察logcat的日志,发现提示很多ClassNotFound的信息,而且 ...

  8. 如何计算一个字符串表示的计算式的值?——C_递归算法实现

    在<C程序设计伴侣>的8.7.3 向main()函数传递数据这一小节中,我们介绍了如何通过main()函数的参数,向程序传递两个数据并计算其和值的简单加法计算器add.exe.这个程序,好 ...

  9. sip比较好的博客

    http://blog.sina.com.cn/s/articlelist_1796220243_1_1.html

  10. 294. Flip Game II

    题目: You are playing the following Flip Game with your friend: Given a string that contains only thes ...