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 |
Re:大牛们帮我看看这段代码,很短,老是WAIn Reply To:大牛们帮我看看这段代码,很短,老师WA Posted by:200830740509 at 2009-08-11 20:46:59 > #include <cstdio> > #include <algorithm> > #include <functional> > #include<cstdlib> > #include<iostream> > #include<cstring> > using namespace std; > char a[8][8]; > bool can[8]; > int n,k; > long c; > void dfs(int i,int num) > { > for(int j=0;j<n;j++) > { > if(a[i][j]=='#'&&can[j]==true) > { > can[j]=false; > num--; > if(i+1<n&&num>0) > dfs(i+1,num); > else if(num==0) > c++; > num++; > can[j]=true; > } > } > } > int main() > { > while(scanf("%d%d",&n,&k)!=EOF) > { > if(n==-1&&k==-1) > break; > for(int i=0;i<8;i++) > can[i]=true; > for(int i=0;i<n;i++) > for(int j=0;j<n;j++) > cin>>a[i][j]; > c=0; > for(int i=0;i<n;i++) > dfs(i,k); > cout<<c<<endl; > } > system("pause"); > return 0; > } > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator