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

m,n,t,c 改为double 就ac了。why?

Posted by ferret088 at 2009-11-30 13:31:13 on Problem 3440
#include<iostream>
#include<cmath>
using namespace std;
#define pi acos(-1.0)
int m,n,t,d;
double r;
void solve( int no ){
	double p[5];
	double s,ts;
	s=m*n*t*t;
	if( m==1 && n==1 ){
		p[1]=1,p[2]=p[3]=p[4]=0;
	}else if( m==1 ){
		ts=(n-1)*d*t;
		p[2]=ts/s,p[3]=p[4]=0;
		ts=2*(t-r)*t+(n-2)*(t-d)*t;
		p[1]=ts/s;
	}else if( n==1 ){
		ts=(m-1)*d*t;
		p[2]=ts/s,p[3]=p[4]=0;
		ts=2*(t-r)*t+(m-2)*(t-d)*t;
		p[1]=ts/s;
	}else {
		ts=4*(t-r)*(t-r)+(m+n-4)*2*(t-d)*(t-r)+(m-2)*(n-2)*(t-d)*
		(t-d);
		p[1]=ts/s;
		ts=(m-1)*(n-1)*pi*r*r;
		p[4]=ts/s;
		ts=(m-1)*(n-1)*(d*d-pi*r*r);
		p[3]=ts/s;
		ts=((n-1)*m+(m-1)*n)*d*t-2*(m-1)*(n-1)*d*d;
		p[2]=ts/s;
	}
	printf("Case %d:\n",no);
	printf("Probability of covering 1 tile  = %.4lf%%\n",p[1]*100.0);
	for( int i=2;i<=4;++i ){
		printf("Probability of covering %d tiles = %.4lf%%\n",i,p[i]*100.0);
    }
	printf("\n");
}

int main(){
	freopen("c:\\data\\data.txt","r",stdin);
	int tn,ts;
	scanf("%d",&tn);
	for( ts=1;ts<=tn;++ts ){
		scanf("%d%d%d%d",&m,&n,&t,&d);
		r=d/2.0;
		solve(ts);
	}
	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