hdu4422 The Little Girl who Picks Mushrooms 暴力

在Gensokyo的世界中,爱丽丝计划在五座山上收集蘑菇,并使用五个袋子来区分不同山上的蘑菇。在返回途中,她需要面对三个淘气精灵的要求,并防止Marisa的蘑菇盗窃,目标是最大化她最终带回家的蘑菇总量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

对网上的题解非常不满,明明那么萌的题干都吐槽不好理解和采蘑菇小姑娘可怜。。。

题意就是说,在幻想乡里,有个爱丽丝要去五个山头采蘑菇回去煮汤(爱丽丝人妻属性爆炸),她带了五个袋子用来分别装每个山头的蘑菇,每个袋子最多容纳2012个蘑菇。n是爱丽丝已经采过的山头和蘑菇数量DA☆ZE。采剩余的山头肯定蘑菇无限多啦

在回魔法森林的途中会碰到三月精(明明三月精都走了),三个人要求交出三个篮子,重量和必须为1024的倍数,不然就把蘑菇全拿走。回家之后会有魔理沙偷蘑菇,每次偷1024个直到剩余蘑菇小于1024个为止,问爱丽丝最多能带回多少蘑菇(我要吐槽魔理沙为什么要偷蘑菇,直接去爱丽丝家拿啊)

唔,做法就是n<=3的时候一定能留下1024个蘑菇,n==4和n==5时枚举就好

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
#include<stack>
using namespace std;
const int N=1005;
typedef long long ll;
int a[6];
int main()
{
    int x,y,n;
    int T;
    int sum=0;
    while(scanf("%d",&n)!=EOF)
    {
    	int sum=0;
    	for(int i=0;i<n;i++)
    	{
			scanf("%d",a+i);
			sum+=a[i];
    	}
    	if(n<=3) printf("1024\n");
    	else if(n==4)
		{
			int maxn = 0;
            for(int i = 0; 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;
            if(maxn == 0)
                for(int i = 0; i < 4; i++)
                    for(int j = i + 1; j < 4; j++)
                        maxn = max(maxn, (a[i] + a[j] - 1) % 1024 + 1);
            printf("%d\n", maxn);
		}
		else
		{
				int ans=0;
				for(int i = 0; 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)
						{
							//printf("an==%d %d %d\n",a[i],a[j],a[k]);
                          	ans = max(ans, (sum - a[i] - a[j] - a[k] - 1) % 1024 + 1);
						}
				printf("%d\n",ans);
		}
    }
    return 0;
}
//过气网红爱丽丝



资源下载链接为: https://pan.quark.cn/s/22ca96b7bd39 在当今的软件开发领域,自动化构建与发布是提升开发效率和项目质量的关键环节。Jenkins Pipeline作为一种强大的自动化工具,能够有效助力Java项目的快速构建、测试及部署。本文将详细介绍如何利用Jenkins Pipeline实现Java项目的自动化构建与发布。 Jenkins Pipeline简介 Jenkins Pipeline是运行在Jenkins上的一套工作流框架,它将原本分散在单个或多个节点上独立运行的任务串联起来,实现复杂流程的编排与可视化。它是Jenkins 2.X的核心特性之一,推动了Jenkins从持续集成(CI)向持续交付(CD)及DevOps的转变。 创建Pipeline项目 要使用Jenkins Pipeline自动化构建发布Java项目,首先需要创建Pipeline项目。具体步骤如下: 登录Jenkins,点击“新建项”,选择“Pipeline”。 输入项目名称和描述,点击“确定”。 在Pipeline脚本中定义项目字典、发版脚本和预发布脚本。 编写Pipeline脚本 Pipeline脚本是Jenkins Pipeline的核心,用于定义自动化构建和发布的流程。以下是一个简单的Pipeline脚本示例: 在上述脚本中,定义了四个阶段:Checkout、Build、Push package和Deploy/Rollback。每个阶段都可以根据实际需求进行配置和调整。 通过Jenkins Pipeline自动化构建发布Java项目,可以显著提升开发效率和项目质量。借助Pipeline,我们能够轻松实现自动化构建、测试和部署,从而提高项目的整体质量和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值