| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请问下这个题目的意思?(内详) 题目是ZJU的2059: http://acm.zju.edu.cn/show_problem.php?pid=2059
请问大牛是不是每个crystal 都要用上啊? 附上我的程序(老是WA~):
#include <stdio.h>
#include <string.h>
#define ROOT 2500
int a[102];
bool f1[5002],f2[5002];
int main() {
int i,j,n;
int sum;
// freopen( "in.txt", "r", stdin );
while( scanf("%d",&n) && n>=0 ) {
sum=0;
for( i=1; i<=n; ++i ) { scanf("%d",&a[i]); sum+=a[i]; }
memset( f1,0,sizeof(f1) );
memset( f2,0,sizeof(f2) );
if( !n ) { printf("Sorry\n"); continue; }
f1[ROOT+a[1]]=true;
f1[ROOT-a[1]]=true;
for( i=2; i<=n; ++i ) {
memset( f2,0,sizeof(f2) );
for( j=-2000; j<=2000; ++j )
if( f1[ROOT+j] ) {
f2[ROOT+j-a[i]]=true;
f2[ROOT+j+a[i]]=true;
}
memcpy( f1,f2,sizeof(f2) );
}
if( f1[ROOT+0] && sum%2==0 ) printf("%d\n",sum/2); else printf("Sorry\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator