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