【瞎搞】 HDU 4422 The Little Girl who Picks Mushrooms
2014-10-19 19:49
232 查看
5-n的包包里面可以任意放0-2012个蘑菇
可以证明n<=3时都输出1024
然后枚举n==4 和n==5
可以证明n<=3时都输出1024
然后枚举n==4 和n==5
#include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <cctype> #include <cmath> #include <string> #include <sstream> #include <iostream> #include <algorithm> #include <iomanip> using namespace std; #include <queue> #include <stack> #include <vector> #include <deque> #include <set> #include <map> typedef long long LL; typedef long double LD; #define pi acos(-1.0) #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 typedef pair<int, int> PI; typedef pair<int, PI> PP; int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int n,a[10],num[10]; while(scanf("%d",&n)!=EOF) { int sum=0; memset(a,0,sizeof(a)); for(int i=0; i<5; i++) num[i]=i; for(int i=0; i<n; i++) { scanf("%d",&a[i]); sum+=a[i]; } if(n<=3) { printf("1024\n"); continue; } else if(n==4) { int out=0; do { int ans=0,x; if(num[0]==4) { ans=sum-a[num[1]]-a[num[2]]; } else if(num[1]==4) { ans=sum-a[num[0]]-a[num[2]]; } else if(num[2]==4) { ans=sum-a[num[1]]-a[num[0]]; } else { int x=a[num[0]]+a[num[1]]+a[num[2]]; if(x%1024!=0) ans=0; else ans=1024; } while(ans>1024) ans-=1024; out=max(ans,out); } while(next_permutation(num,num+5)); cout<<out<<endl; } else { int out=0; do { int ans=0; int x=a[num[0]]+a[num[1]]+a[num[2]]; if(x%1024) ans=0; else ans=sum-x; while(ans>1024) ans-=1024; out=max(ans,out); } while(next_permutation(num,num+5)); cout<<out<<endl; } } return 0; }
相关文章推荐
- 【瞎搞】 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 (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(水题)
- 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
- 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(模拟)