HDU 4422 The Little Girl who Picks Mushrooms(简单题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4422
题目大意:小姑娘背着5个包去山上采蘑菇,每座山上只能用一个背包采集。三个小精灵会要她3个背包,其里面蘑菇的数量必须是1024的倍数,否则5个背包都会被拿走。然后魔术师会从她剩下的背包里取走蘑菇,每次取1024克,直到蘑菇不超过1024克为止。求小姑娘最多能得到多少蘑菇。
代码如下:
# include<stdio.h>
# include<algorithm>
# include<iostream>
using namespace std; int n,a[],sum,ans; int calc(int x)
{
while(x > )
x -= ;
return x;
} void solve()
{
for(int i=; i<n; i++)
for(int j=i+; j<n; j++)
if(n== || (sum-a[i]-a[j])%==)
ans = max(ans,calc(a[i]+a[j]));
} int main()
{
while(scanf("%d",&n)!=EOF)
{
sum = ,ans = ;
for(int i=; i<n; i++)
{
scanf("%d",&a[i]);
sum += a[i];
}
if(n<=)
ans = ;
else if(n==)
for(int i=; i<; i++)
if((sum-a[i])%==)
ans = ;
if(ans!=)
solve();
printf("%d\n",ans);
}
return ;
}
HDU 4422 The Little Girl who Picks Mushrooms(简单题)的更多相关文章
- 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 ...
- HDU 4422 The Little Girl who Picks Mushrooms ( 模拟)
Problem Description It's yet another festival season in Gensokyo. Little girl Alice planned to pick ...
- HDU 4422 The Little Girl who Picks Mushrooms
题意:一共有5座山,已知小女孩在n座山采了n篮蘑菇,如果n小于5则在其他的山里采了任意重量的蘑菇,给出每篮蘑菇的重量,她回去的时候会遇到仨女巫要她交出三篮蘑菇的重量和恰好为1024的倍数,否则就把她的 ...
- HDU 1316 How Many Fibs?(java,简单题,大数)
题目 /** * compareTo:根据该数值是小于.等于.或大于 val 返回 -1.0 或 1: public int compareTo(BigInteger val) 将此 BigInteg ...
- HDU - 2199 Can you solve this equation? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 5999 The Third Cup is Free 贪心 简单题
The Third Cup is Free Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- 2015多校联合训练赛hdu 5301 Buildings 2015 Multi-University Training Contest 2 简单题
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 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 ...
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
随机推荐
- oracle的commit
oracle的commit就是提交数据(释放锁),在未提交前你前面的操作更新的都是内存,没有更新到物理文件中.执行commit从用户角度讲就是更新到物理文件了,事实上commit时还没有写date f ...
- 手把手教你去ECSHOP版权 powered by ecshop
各位朋友大家好,欢迎来到ecshop开发中心系列视频教程:ecshop去版权.去版权是一种很常见的问题,有很多客户提到ECSHOP如何去版权?怎样去得干净.去得彻底?今天,ECSHOP开发中心手把 ...
- 单点登录系统CAS筹建及取得更多用户信息的实现
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- metasploit(MSF)终端命令大全
show exploits 列出metasploit框架中的所有渗透攻击模块. show payloads 列出metasploit框架中的所有攻击载荷. show auxiliary 列 ...
- java_jdbc_spring框架查询操作简例
1.添加commons-dbcp-1.4,commons-logging,commons-pool-1.2//线程池,commons.collections-3.2.1.jar,spring.jar ...
- OpenCms Application dev-ref
OpenCms Application Overview Before undertaking development, it will be helpful to understand the ba ...
- 通过scrollerview自定义collectionview(常用于推荐关注界面)
最近项目上要实现一个效果,先把效果图摆上来吧: 刚看到效果图的时候 我觉得很简单 用UICollectionview就可以了 但是后来发现collectionview只有两种布局方式 比较单一 ...
- Java安全防御学习笔记V1.0
Java安全防御学习笔记V1.0http://www.docin.com/p-766808938.html
- StringBuilder 用法和div获取
StringBuilder strHtml = new StringBuilder(); strHtml.Append("<tr>"); strHtml.Append( ...
- posix thread互斥量
互斥量 互斥量(Mutex)是“mutual exclusion”的缩写.互斥量是实现线程同步,和保护同时写共享数据的主要方法.使用互斥量的典型顺序如下:1. 创建和初始一个互斥量 2. 多个线程尝试 ...