程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> The 37th ACM/ICPC Asia Regional ChangChun Site Contest - C T

The 37th ACM/ICPC Asia Regional ChangChun Site Contest - C T

編輯:C++入門知識

   題意略坑...給的modulo 20121014 是忽悠人的...用不上..因為答案最多最多1024...數據量小..分情況討論..

Program:
[cpp]
#include<iostream> 
#include<stdio.h> 
#include<string.h> 
#include<math.h> 
#include<algorithm> 
#include<stack> 
#include<queue> 
#include<set> 
#define ll long long 
using namespace std; 
int n,a[10],ans,sum; 
int main() 
{  
       int i,j,k,m; 
       while (scanf("%d",&n)!=EOF) 
       { 
               ans=sum=0; 
               for (i=1;i<=n;i++) 
               { 
                      scanf("%d",&a[i]); 
                      sum+=a[i]; 
               } 
               if (n<4) ans=1024; 
               else 
               if (n==4) 
               { 
                      for (i=1;i<=4;i++) 
                         for (j=i+1;j<=4;j++) 
                         { 
                                m=a[i]+a[j]; 
                                while (m>1024) m-=1024; 
                                if (m>ans) ans=m; 
                         } 
                      for (i=1;i<=4;i++) 
                         for (j=i+1;j<=4;j++) 
                            for (k=j+1;k<=4;k++) 
                              if ((a[i]+a[j]+a[k])%1024==0) ans=1024; 
               }else 
               { 
                      for (i=1;i<=5;i++) 
                         for (j=i+1;j<=5;j++) 
                            for (k=j+1;k<=5;k++) 
                            if ((a[i]+a[j]+a[k])%1024==0) 
                            { 
                                    m=sum-a[i]-a[j]-a[k]; 
                                    while (m>1024) m-=1024; 
                                    if (m>ans) ans=m; 
                            } 
               } 
               printf("%d\n",ans); 
       } 
       return 0; 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved