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

Re:看看这么怎么老说WA

Posted by flykite at 2005-12-23 11:17:50 on Problem 1491
In Reply To:看看这么怎么老说WA Posted by:flykite at 2005-12-23 11:12:11
自己测试了几个都没有问题
1到底和其他说互不互质? 我这里算作是的
> #include "stdio.h"
> #include "stdlib.h"
> #include "math.h"
> 
> int main()
> {
> 	while(1)
> 	{
> 		int *set;
> 		int times;
> 		int i,j,a,b,c=0,count=0;
> 		double pi=0.0;
> 		scanf("%d", ×);
> 		if(times==0) break;
> 		set = (int*)malloc(sizeof(int)*times);
> 		for(i=0; i<times; i++)
> 			scanf("%d", &set[i]);
> 		for(i=0; i<times; i++)
> 			for(j=i+1; j<times; j++)
> 			{
> 				a = set[i]>set[j]?set[i]:set[j];
> 				b = set[j]+set[i]-a;
> 				while(c=a%b)
> 				{
> 					a=b;
> 					b=c;
> 				}
> 				if(b==1) count++;
> 			}
> 		if(count)
> 		{
> 			pi = sqrt(3*times*(times-1)/count);
> 			printf("%.6lf\n", pi);
> 		}
> 		else
> 			printf("No estimate for this data set.\n");
> 		free(set);		
> 	}
> 
> 	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