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 36211316 at 2007-03-01 13:37:39 on Problem 1189
#include<stdio.h>
#include<math.h>

int n,m,a[50][50]={0},b[51]={0};

void abc(int x,int y,int t){
	if(y<n){
		if(a[y][x]==1){
			abc(x,y+1,t-1);
			abc(x+1,y+1,t-1);
		}else{
			abc(x+1,y+2,t);
		}
	}
	else{
		b[x]+=(int)pow(2,t);
	}
}
void printf_abc(void){
	int i,sum=0;

	for(i=0;i<n+1;++i){
		sum+=b[i];
	}
	for(i=2;i<=b[m];++i){
		if(b[m]%i==0&&sum%i==0){
			b[m]/=i;
			sum/=i;
			--i;
		}
	}
	if(b[m]==0)
		printf("0/1");
	else
		printf("%d/%d",b[m],sum);
}
int main(){
	int i,j;
	char c;

	scanf("%d %d",&n,&m);
    fflush(stdin);
	for(i=0;i<n;i++){
		for(j=0;j<=i;j++){
			while((c=getchar())==' '||c=='\n');
			if(c=='*'){
				a[i][j]=1;
			}
			else{
				a[i][j]=0;
			}
		}
	}
	abc(0,0,n);
	printf_abc();

	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