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

But, I already checked that in my program.

Posted by kcm1700 at 2006-06-04 18:42:15 on Problem 2830
In Reply To:Re:Is there any special cases? Posted by:frkstyc at 2006-05-28 19:40:19
Here`s my code... 
(very dirty )...
What`s wrong?

#include <stdio.h>
#include <math.h>
int n;
double admax;
int admax_n;

int main(){
	int i;
	double dmax,ndmax;
	double dmin,ndmin;
	int dmax_n=0,ndmax_n=0;
	int dmin_n=0,ndmin_n=0;
	double dat;
	while(scanf("%d",&n)!=EOF){
		admax_n=dmax_n=ndmax_n=dmin_n=ndmin_n=admax=0;
		for(i=0;i<n;i++){
			scanf("%lf",&dat);
			if(!i){
				admax=dat;
				dmax=dat;
				dmin=dat;
				admax_n=dmax_n=dmin_n=0;
				if(dat!=0){
					while(fabs(admax) < 0.9995){
						admax*=10;
						admax_n--;
					}
					while(fabs(dmax) < 0.9995){
						dmax*=10;
						dmax_n--;
					}
					while(fabs(dmin) < 0.9995){
						dmin*=10;
						dmin_n--;
					}
					while(fabs(admax) >= 9.9995){
						admax/=10;
						admax_n++;
					}
					while(fabs(dmin) >= 9.9995){
						dmin/=10;
						dmin_n++;
					}
					while(fabs(dmax) >= 9.9995){
						dmax/=10;
						dmax_n++;
					}
				}
			}else{
				ndmax=dat;
				ndmin=dat;
				if(ndmin!=0){
					while(fabs(ndmin) < 0.9995){
						ndmin*=10;
						ndmin_n--;
					}
					while(fabs(ndmin) >= 9.9995){
						ndmin/=10;
						ndmin_n++;
					}
				}else ndmin_n=0;
				if(ndmax!=0){
					while(fabs(ndmax) < 0.9995){
						ndmax*=10;
						ndmax_n--;
					}
					while(fabs(ndmax) >= 9.9995){
						ndmax/=10;
						ndmax_n++;
					}
				}else ndmax_n=0;
				dmax*=dat;
				dmin*=dat;
				if(dmin!=0){
					while(fabs(dmin) < 0.9995){
						dmin*=10;
						dmin_n--;
					}
					while(fabs(dmin) >= 9.9995){
						dmin/=10;
						dmin_n++;
					}
				}else dmin_n=0;
				if(dmax!=0){
					while(fabs(dmax) < 0.9995){
						dmax*=10;
						dmax_n--;
					}
					while(fabs(dmax) >= 9.9995){
						dmax/=10;
						dmax_n++;
					}
				}else dmax_n=0;
				if((ndmax<0 && dmax==0) || (!ndmax&&dmax>0)||(dmax > ndmax && dmax_n == ndmax_n) || (dmax_n > ndmax_n && dmax>0 && ndmax > 0) || (dmax > 0 && ndmax < 0) || (dmax<0 && ndmax<0 && dmax_n < ndmax_n)){
					ndmax = dmax;
					ndmax_n = dmax_n;
				}
				if((ndmax<0 && dmin==0) || (!ndmax&&dmin>0)||(dmin > ndmax && dmin_n == ndmax_n) || (dmin_n > ndmax_n && dmin>0 && ndmax > 0) || (dmin > 0 && ndmax < 0) || (dmin<0 && ndmax<0 && dmin_n < ndmax_n)){
					ndmax = dmin;
					ndmax_n = dmin_n;
				}
				if((ndmin>0 && dmax==0) || (!ndmin&&dmax<0)||(dmax < ndmin && dmax_n == ndmin_n) || (dmax_n < ndmin_n && dmax>0 && ndmin > 0) || (dmax < 0 && ndmin > 0) || (dmax<0 && ndmin<0 && dmax_n > ndmin_n)){
					ndmin = dmax;
					ndmin_n = dmax_n;
				}
				if((ndmin>0 && dmin==0) || (!ndmin&&dmin<0)||(dmin < ndmin && dmin_n == ndmin_n) || (dmin_n < ndmin_n && dmin>0 && ndmin > 0) || (dmin < 0 && ndmin > 0) || (dmin<0 && ndmin<0 && dmin_n > ndmin_n)){
					ndmin = dmin;
					ndmin_n = dmin_n;
				}
				dmax_n = ndmax_n;
				dmin_n = ndmin_n;
				dmax = ndmax;
				dmin = ndmin;
				if(dmin!=0){
					while(fabs(dmin) < 0.9995){
						dmin*=10;
						dmin_n--;
					}
					while(fabs(dmin) >= 9.9995){
						dmin/=10;
						dmin_n++;
					}
				}else dmin_n=0;
				if(dmax!=0){
					while(fabs(dmax) < 0.9995){
						dmax*=10;
						dmax_n--;
					}
					while(fabs(dmax) >= 9.9995){
						dmax/=10;
						dmax_n++;
					}
				}else dmax_n=0;
			}
			if((admax<0 && dmax==0)||(admax==0&&dmax>0)||(dmax > admax && dmax_n == admax_n) || (dmax_n > admax_n && dmax>0 && admax > 0) || (dmax > 0 && admax < 0) || (dmax<0 && admax<0 && dmax_n < admax_n)){
				admax = dmax;
				admax_n = dmax_n;
			}
		}
		if(admax!=0){
			while(fabs(admax) < 0.9995){
				admax*=10;
				admax_n--;
			}
			while(fabs(admax) >= 9.9995){
				admax/=10;
				admax_n++;
			}
		}else admax_n=0;
		if(admax_n){
			printf("%.3lfE%d\n",admax,admax_n);
		}else{
			printf("%.3lf\n",admax);
		}
	}
	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