Hdu 4422 The Little Girl who Picks Mushrooms
2013-08-17 11:07
232 查看
题意:有五座山,已知小女孩已经采过了的山,另外还剩下的(5-n)座山可以去采,出口时必须要把三个袋子之和为1024克的整数倍给Sunny, Lunar and Star,没有就全部留下袋子,女孩手中的蘑菇=0,若有符合的三个袋子,出口后回家的路上被Marisa重复拿走1024克,知道女孩手中剩下不多于1024克的蘑菇,问最终女孩最多能有多少蘑菇
思路:n<=3的时候:另外的山肯定可以使最后回去的时候达到最大值1024
n==4的时候:枚举三个可以凑成1024的整数倍,否则,就拿另外一个山来补
n==5的时候:全部枚举
代码:
思路:n<=3的时候:另外的山肯定可以使最后回去的时候达到最大值1024
n==4的时候:枚举三个可以凑成1024的整数倍,否则,就拿另外一个山来补
n==5的时候:全部枚举
代码:
#include <iostream> #include <stdio.h> #include <cmath> #include <cstring> #include <algorithm> #include <vector> #include <map> using namespace std; const int M=1e5+5; const int mod=1e9+7; int a[6]; int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) scanf("%d",&a[i]); int sum=0,ans; if(n<=3) { printf("1024\n"); continue; } if(n==4) { ans=0; for(int i=1;i<=4;i++) { for(int j=1;j<=4;j++) { for(int k=1;k<=4;k++) { if(i!=j && j!=k && i!=k) { int t=a[i]+a[j]+a[k]; if(t%1024==0) { ans=1024; i=5,j=5,k=5; } } } } } if(ans==1024) { printf("1024\n"); continue; } for(int i=1;i<=4;i++) { for(int j=1;j<=4;j++) { if(i!=j) { int t=0; for(int k=1;k<=4;k++) { if(k!=i && k!=j) { t+=a[k]; } } while(t>1024) t-=1024; if(t>sum) sum=t; } } } printf("%d\n",sum); continue; } if(n==5) { int ff=0; for(int i=1;i<=5;i++) { for(int j=1;j<=5;j++) { for(int k=1;k<=5;k++) { if(i==j || i==k || j==k)continue; int t=a[i]+a[j]+a[k]; ans=0; if(t%1024==0) { ff=1; for(int x=1;x<=5;x++) { if(x!=i && x!=j && x!=k) { ans+=a[x]; } } while(ans>1024) ans-=1024; if(ans>sum) sum=ans; } } } } if(ff==0)printf("0\n"); else printf("%d\n",sum); } } return 0; }
相关文章推荐
- hdu 4422 The Little Girl who Picks Mushrooms
- The Little Girl who Picks Mushrooms HDU - 4422
- HDU 4422 The Little Girl who Picks Mushrooms(模拟)
- hdu 4422 The Little Girl who Picks Mushrooms【贪心+分类讨论】
- HDU 4422 The Little Girl who Picks Mushrooms【水题】
- 【瞎搞】 HDU 4422 The Little Girl who Picks Mushrooms
- C - The Little Girl who Picks Mushrooms HDU - 4422
- 【瞎搞】 HDU 4422 The Little Girl who Picks Mushrooms
- hdu 4422 The Little Girl who Picks Mushrooms
- hdu 4422——The Little Girl who Picks Mushrooms
- HDU 4422 The Little Girl who Picks Mushrooms(数学)
- hdu(4422)The Little Girl who Picks Mushrooms
- The Little Girl who Picks Mushrooms(HDU - 4422)枚举 数学
- hdu 4422 The Little Girl who Picks Mushrooms(水题)
- HDU 4422 The Little Girl who Picks Mushrooms (2012年长春赛区现场赛C题)
- HDU 4422 The Little Girl who Picks Mushrooms(简单题)
- HDU 4422 The Little Girl who Picks Mushrooms(数学)
- HDU 4422 The Little Girl Who Picks Mushrooms
- HDU 4422 The Little Girl who Picks Mushrooms(模拟)
- HDU 4422 The Little Girl who Picks Mushrooms(数学)