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 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 ≤ w i  ≤ 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;
}
//过气网红爱丽丝



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值