Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

顶楼上的!!

Posted by Sempr at 2006-07-10 19:37:47 on Problem 1745
In Reply To:为什么会WA,我的思路很清晰呀?(我还发现,好象数据一长就读不进去了) Posted by:linmeng at 2005-08-08 14:16:31
> #include <iostream.h>
> #include <stdio.h>
> #include <stdlib.h>
> long a[10000];
> long n,k;
> void work(int i,long sum)
>  {
>   if (i>n){
> 	    if (sum %k==0) {
> 			    printf("Divisible\n");
> 			    exit(0);
> 			   }
> 	  }
>      else {
> 	   work(i+1,sum+a[i]);
> 	   work(i+1,sum-a[i]);
> 	  }
>  }
> int main()
>  {
>   cin>>n>>k;
>   memset(a,0,sizeof(a));
>   int i;
>   for (i=1;i<=n;i++) cin>>a[i];
>   work(2,a[1]);
>   printf("Not divisible\n");
>   return 0;  
>  }
>    

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator