hdu 4422 The Little Girl who Picks Mushrooms(水题)

Fanuc机器人的坐标变换矩阵的研究2 一、Funuc用户坐标系的介绍 二、用户坐标系与世界坐标系的坐标转换 三、 以用户坐标系1为基础旋转变换后的用户坐标系 四、关于点的WPR的含义 4.1:点在用户坐标系和世界坐标系下的坐标关系 4.2 通过转换矩阵返回去推导WPR 阅读详情

The Little Girl who Picks Mushrooms

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3168    Accepted Submission(s): 1037


Problem Description
It's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from different mountains. Each bag has a capacity of 2012 grams. Alice has finished picking mushrooms in 0 ≤ n ≤ 5 mountains. In the i-th mountain, she picked 0 ≤ wi ≤ 2012 grams of mushrooms. Now she is moving forward to the remained mountains. After finishing picking mushrooms in all the five mountains, she want to bring as much mushrooms as possible home to cook a delicious soup.
Alice lives in the forest of magic. At the entry of the forest of magic, live three mischievous fairies, Sunny, Lunar and Star. On Alice's way back home, to enter the forest, she must give them exactly three bags of mushrooms whose total weight must be of integral kilograms. If she cannot do so, she must leave all the five bags and enter the forest with no mushrooms.
Somewhere in the forest of magic near Alice's house, lives a magician, Marisa. Marisa will steal 1 kilogram of mushrooms repeatedly from Alice until she has no more than 1 kilogram mushrooms in total. So when Alice gets home, what's the maximum possible amount of mushrooms Alice has? Remember that our common sense doesn't always hold in Gensokyo. People in Gensokyo believe that 1 kilogram is equal to 1024 grams.
 

Input
There are about 8192 test cases. Proceed to the end of file.
The first line of each test case contains an integer 0 ≤ n ≤ 5, the number of mountains where Alice has picked mushrooms. The second line contains n integers 0 ≤ wi ≤ 2012, the amount of mushrooms picked in each mountain.
 

Output
For each test case, output the maximum possible amount of mushrooms Alice can bring home, modulo 20121014 (this is NOT a prime).
 

Sample Input
1 9 4 512 512 512 512 5 100 200 300 400 500 5 208 308 508 708 1108
 

Sample Output
1024 1024 0 792
Hint
In the second sample, if Alice doesn't pick any mushrooms from the 5-th mountain. She can give (512+512+0) =1024 grams of mushrooms to Sunny, Lunar and Star. Marisa won't steal any mushrooms from her as she has exactly 1 kilogram of mushrooms in total. In the third sample, there are no three bags whose total weight is of integral kilograms. So Alice must leave all the five bags and enter the forest with no mushrooms. In the last sample: 1.Giving Sunny, Lunar and Star: (208+308+508)=1024 2.Stolen by Marisa: ((708+1108)-1024)=792

题意:alice去五座山上采蘑菇,每座山采蘑菇的数量范围都是0 ≤ w i ≤ 2012。当采完蘑菇后,alice要恰好拿出三袋来且三袋的蘑菇数总和为1024的整数倍。否则,蘑菇清零。剩下的两袋蘑菇数量如果大于1024,巫婆会取走1024个蘑菇直到袋里的蘑菇不足1024,问alice最大能带多少蘑菇回家?


思路:可以推出如果n(n<=3),那么alice总有办法能将恰好3袋为1024整数倍且剩下来袋能为1024。所以只需要考虑n=4和n=5的这两种情况了。
n=5时,用三个for来枚举出所有的情况,取最大的就行了。
n=4时,有两种取法。一种是取两袋确定的一袋不确定的,因为可以取的范围是0~2012,2012>1024,所以一定有办法能让三袋恰好达到1024整数倍。剩下的再根据规则算就好。
另一种是取三袋确定的,只需在这确定四袋中枚举三袋讨论所有情况,如果有达标的,那么最后就可以得到1024个蘑菇。
注意:0也是1024的整数倍。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int mod=20121014;
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int a[10];
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        if(n<=3)
            printf("%d\n",1024);
        else if(n==4)
        {
            int maxn=0;
            for(int i=1;i<=4;i++)
            {
                for(int j=i+1;j<=4;j++)
                {
                    for(int k=j+1;k<=4;k++)
                    {
                        if((a[i]+a[j]+a[k])%1024==0)
                        {
                            maxn=1024;
                        }
                    }
                }
            }
            for(int i=1;i<=4;i++)
            {
                for(int j=i+1;j<=4;j++)
                {
                    int sum=a[i]+a[j];
                    while(sum>1024)
                    {
                        sum-=1024;
                    }
                    if(sum>maxn)
                        maxn=sum;
                }
            }
            printf("%d\n",maxn);
        }
        else
        {
            int maxn=0;
            for(int i=1;i<=5;i++)
            {
                for(int j=i+1;j<=5;j++)
                {
                    for(int k=j+1;k<=5;k++)
                    {
                        if((a[i]+a[j]+a[k])%1024==0)
                        {
                            int sum=0;
                            for(int l=1;l<=5;l++)
                            {
                                if(l!=i&&l!=j&&l!=k)
                                    sum+=a[l];
                            }
                            while(sum>1024)
                            {
                                sum-=1024;
                            }
                            if(sum>maxn)
                                maxn=sum;
                        }
                    }
                }
            }
            printf("%d\n",maxn);
        }
    }
    return 0;
}


量化交易 米筐 案例:市值因子选股策略 案例:市值因子的选股策略 1.结果 获得超额收益 年化 49% 2. 从股票中选择市值小的股票 选定财务数据筛选 进行每日调仓(多因子选股调仓 周期频率会小一些) 3. 代码 估值有关指标 # 在沪深300股票中,选出市值比较小的10只股票 # 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。 def init(context): # 沪深300组合 stocks = index_components('000300.XSHG') # 沪深3 阅读详情

相关推荐

自适应粒子群优化(Adaptive Particle Swarm Optimization,APSO

下面是一个关于自适应粒子群优化(Adaptive Particle Swarm Optimization,APSO)的博客,希望可以帮助您。提示:以下是本篇文章正文内容,下面案例可供参考在上面的代码中,表示粒子的数量,表示解空间的维度,表示迭代次数,表示优化的目标函数。在__init__方法中,我们初始化了粒子群的位置和速度,并将每个粒子的位置作为其最优解,将其适应度值初始化为正无穷。我们还初始化了学习因子和惯性权重的参数。在run方法中,我们迭代了次,计算每个粒子的适应度值和最优解。

weixin_52026057的博客 9916

C - The Little Girl who Picks Mushrooms HDU - 4422

题目链接:点击打开链接 Alice 在五座山上采蘑菇,已知她已经采了 n 座山(0 暑假集训的一道题,题意好理解,结果做了好长时间也没做出来,后来看了别人的代码,结果发现思路一样,代码写的也基本一样,实在不明白哪错,后来改了又改,才对了,气死人。(做这道题的时候我在想Alice过的是啥生活,感觉好悲惨啊!!!!!!!!!!!!!!!!!!!!!) 最后附上代码: #inc

你的你的都是你的的博客 346

BDD测试之Behave使用入门

BDD测试(Behavior-Driven Development Testing)是一种基于“行为驱动开发”(BDD)理念。

想要成为酷盖但是失败的小明 580

zoj The Little Girl who Picks Mushrooms

The Little Girl who Picks Mushrooms Time Limit: 2 Seconds Memory Limit: 32768 KB It's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. S

习惯与规则决定命运 1013

手把手复现论文:SVPWM过调制I区与II区算法仿真(附MATLAB源码)

本文详细介绍了SVPWM过调制I区与II区算法的MATLAB仿真实现,从理论推导到Simulink建模逐步解析。通过源码示例展示幅值补偿和六边形跟踪等关键技术,帮助电力电子研究者掌握过调制算法的核心实现方法,适用于电机控制、变频器等工业应用场景。

weixin_28739079的博客 530

车企常用架构、通信设计、需求管理工具全汇总

车辆技术是个系统工程,比较大,需要多人协作。“协作”往往需要工具参与,才能保证协作过程的高效、有条不紊。 【文章系转载,出处见图片水印】 今天我们就来捋一捋汽车行业常用的架构、网络开发工具~ Preevision 大名鼎鼎的Preevision,来自大名鼎鼎的Vector。 个人觉得,它是Vector公司最牛逼、最神秘、最高高在上的产品,犹如空谷回响、千里传音,但是很少看到它真正落地。 它最引以为傲的,或许是在给客户做介绍的时候,说“我们甚至能够精确到每一根线束的长度”,但是反观.

MaveDiao的博客 3485

The Little Girl who Picks Mushrooms

It’s yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from different m

退役的铜牌狗 408

Android逆向分析

Android 逆向开发是指对已发布的 Android 应用进行分析和破解,以了解应用程序的内部工作原理,获取应用程序的敏感信息,或者修改应用程序的行为。Android应用 Java编写的,利用Android SDK编译代码,并并且把所有的数据和资源文件打包成一个APK(Android Package)文件这是一个后缀名为.apk的压缩文件,apk文件中包含了一个Anddroid应用程序的所有内容,是Android平台用于安装应用程序的文件。

qq_51598534的博客 6294

HDU 4422 The Little Girl who Picks Mushrooms

HDU 4422 The Little Girl who Picks Mushrooms 题意:在幻想乡的一天,爱丽丝准备去五座山上去采蘑菇。她带了五个袋子,每到一座山,她就用一个袋子来装蘑菇。爱丽丝想尽可能多地带蘑菇回家做美味的蘑菇汤。不过爱丽丝居住的魔法森林有三个妖精——桑尼、露娜和斯塔,爱丽丝必须给她们三袋子蘑菇,这些蘑菇总数必须为整数千克。 Sample Input 1 9 4 512 5...

muyu__的博客 454

基于Python实现身份证信息识别

身份证是一种重要的证件,包含了个人的基本信息,如姓名、性别、出生日期、住址等。在实际应用中,有时需要对身份证进行自动化的识别,以提高工作效率和准确性。本文将介绍如何使用Python实现身份证信息的识别,通过图像预处理、OCR技术和解析算法,实现对身份证号码和其他信息的提取和解析。

商务合作 / 项目定制 / 学习交流。个人vx:lovely_wml 1万+

微信终于支持“多设备同时在线”?我用 NAS + Docker 搭了一个云端微信系统,多端共享24小时在线

通过Docker 容器,将微信运行在云端并通过浏览器访问,实现多设备共享同一微信会话 📱。本文详细介绍完整部署流程、docker-compose 配置及资源控制方案,让微信变成“可访问的云桌面应用” ✨

XiaoqiangClub的博客 871

hdu 4422 The Little Girl who Picks Mushrooms【贪心+分类讨论】

The Little Girl who Picks Mushrooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2631    Accepted Submission(s): 843 Problem Descript

mengxiang000000 521

锁的艺术:Java并发中的常用锁策略与实践

对java锁相关内容进行整理分析:乐观锁 VS 悲观锁+自旋锁 VS 适应性自旋锁+无锁 VS 偏向锁 VS 轻量级锁 VS 重量级锁+公平锁 VS 非公平锁+可重入锁 VS 非可重入锁+独享锁 VS 共享锁

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 171万+

HDU 4422 The Little Girl who Picks Mushrooms【水题】

The Little Girl who Picks Mushrooms Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2717Accepted Submission(s): 890 Problem Des...

aaf76097的博客 148

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

The Little Girl who Picks Mushrooms HDU 4422 水题类似模拟的一种感觉

The Little Girl who Picks Mushrooms Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1070Accepted Submission(s): 346 Problem Description I...

weixin_30725315的博客 144

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

HDU4422 The Little Girl who Picks Mushrooms【水题】

给出n个数,n小于等于5,不足5个数的剩下的自定,然后,先选3个数的和是1024的整数倍,如果没有则输出0,剩下两个数的和每次减1024直到小于等于1024为止 解法可以看这里,http://www.cnblogs.com/kuangbin/archive/2012/10/16/2725626.html   水题,只想说,剩下两个数的和每次减1024直到小于等于1024为止,要么你写whil

Rainto的专栏 780

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

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

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

1741

hdu4422 The Little Girl who Picks Mushrooms

此题要注意一些细节: 当n<=3时,ans=1024 当n=4时,若有三个固定值的和是1024的倍数,ans=1024,否则枚举剩下的两个固定值的和取最佳 当n=5时,枚举三个固定值看是否为1024的倍数,若有,用剩下2个的和更新答案 有一个坑点,直接模上1024求ans会出问题,得分0,1024的正数倍,和其他三种情况讨论 代码有点搓,观看请慎重。 #in...

akk99296的博客 154

hdu 4422The Little Girl who Picks Mushrooms

Problem Description It's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mush

wenjie2012的专栏 699

hdu4422 The Little Girl who Picks Mushrooms 暴力

It's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from different

thunderMrbird的博客 705

HDU - 4422 The Little Girl who Picks Mushrooms

题意:有5个背包,分别装着5座山上采的蘑菇,已知在其中n(1<=n<=5)座山上采的蘑菇数量,剩下的5-n座未知,采完后,要求有3个背包的蘑菇重量正好是1024的整数倍,求另外两个背包重量和不断被拿走1024直至重量不超过1024后的最大值。 分析:剩下的5-n座未知是解题关键。背包容量为2012。显然,最终的背包重量和最多为1024。 1、n=1,剩下的4个未知包中拿出...

Cherrychan2014的博客 163

HDU 4422 The Little Girl who Picks Mushrooms (2012年长春赛区现场赛C题)

1.题目描述:点击打开链接 2.解题思路:本题是一道简单模拟题,然而,自己的方法不对WA了很多次==。最后不得不弃用自己的思路了。首先用-1表示还没有使用过的位置。可以每次枚举3个位置,如果发现这3个位置中没有-1且他们的和不能被1024整除,那么return 0,否则,找到没有被标记的另外2个位置,如果这2个位置其中一个为-1,那么直接返回1024,因为我们已经交了三个袋子了,剩下的袋子中如果

Skyline 809

The Little Girl who Picks Mushrooms HDU - 4422

当n 当n=4时 两种情况 1.选已采集的两包蘑菇,跟待采集的1包凑成1024的整数倍,让剩下的最多 已存在3包能凑成整数倍,待采集的那一包跟已采集的凑成1024 N=5时判断有没有3包组成1024的整数倍即可。 但是n为4或5时有个很坑的地方就是可以给仙女0个。 #include #include #include using namespace std;   int ma

mayuqing98的博客 246

The Little Girl who Picks Mushrooms(HDU - 4422)枚举 数学

利用枚举解决该问题。

Alexa_cheng 342

hdu 4422 The Little Girl who Picks Mushrooms

学长说这是水题!可是俺连题目都没搞不懂!!! #include #define max(a,b) a>b?a:b int main() { int n,num[10],i,j,q,flag,temp,ans,k; while(scanf("%d",&n)!=EOF) { flag=0; for(i=1;i scanf("%d",&num[i]); if(n prin

YAN 781
上一篇: zoj 3829 Known Notation (贪心)
下一篇: hdu 4424 Conquer a New Region(并查集+贪心)
Timeclimber
博客等级 码龄9年 25粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值