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 ...
随机推荐
- session 重写进入redis测试
在实际业务中,当session存储过多 或者操作频繁,业务逐渐扩展的时候,文件存储已经无法满足session操作速度和需求,可以考虑用数据库或者nosql的redis来存储session,本文讲解如何 ...
- MySQL 子查询 EXISTS 和 NOT EXISTS
MySQL EXISTS 和 NOT EXISTS 子查询 MySQL EXISTS 和 NOT EXISTS 子查询语法如下: SELECT ... FROM table WHERE EXISTS ...
- CentOS6.2下安装eclipse
在eclipse官网下载eclipse的linux版本(此处省略下载过程),我下载的是eclipse-jee-indigo-SR2-linux-gtk.tar.gz,下面是安装过程: 1.sudo ...
- Redis实战之征服 Redis + Jedis + Spring (一)
Redis + Jedis + Spring (一)—— 配置&常规操作(GET SET DEL)接着需要快速的调研下基于Spring框架下的Redis操作. 相关链接: Redis实战 Re ...
- 显示 png 图片
uses pngimage;{显示 png 图片}procedure TForm1.Button2Click(Sender: TObject);var png: TPngImage;begin ...
- SQL Server 性能优化3 该指数(Index)保养
前言 之前的一篇文章介绍了索引来提高数据库的查询性能,这其实仅仅是个开始.也许假设缺乏适当的保养,索引你以前建立的,甚至成为拖累,成为帮凶下降数据库的性能. 寻找碎片 消除碎片索引维护可能是最常规的任 ...
- Android Sqlite 导入CSV文件 .
http://blog.csdn.net/johnnycode/article/details/7413111 今天遇到 Oracle 导出的12万条CSV格式数据导入 Android Sqlite ...
- Hibernate中SQLite方言
package com.lain.util; /** * 2013-7-25 * chongzhen_zhao * SQLite方言 */ import java.sql.Types; import ...
- MySQL入门笔记
MySQL入门笔记 版本选择: 5.x.20 以上版本比较稳定 一.MySQL的三种安装方式: 安装MySQL的方式常见的有三种: · rpm包形式 · 通用二进制 ...
- FIO工具常用参数
name 可能被用于覆盖作业的名称. filename fio 通常基于该作业名称,线程编号,构成一个文件名称和位置.如果您不想让线程之间的共享文件在一个作业或作业.指定文件名都以覆盖默认的. loc ...