| ||||||||||
| 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 | |||||||||
顶楼上的!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator