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

为什么TLE??高手来解释一下:

Posted by zhb_msqx at 2007-08-17 10:46:30 on Problem 1411
#include <math.h>
#include <iostream>
using namespace std;


int area,a,b;

bool isprime(int n){
	if(n==2||n==3)return true;
	if(n%2==0)return false;
	if(n%3==0)return false;
	int t=4;
	for(int k=5;k<n/2;k=k+t){
		if(n%k==0)return false;
		t=6-t;
	}
	return true;
}


void mysch(int p,double rate){
	int p1,p2;
	bool test=true;

	int maxarea=0;
	for(int i=2;test;i++){
		if(i*i*rate>p)test=false;
		if(isprime(i)){
			for(int j=i*rate;j<=i&&test;j++){
				if(isprime(j)){		
					if(i*j>maxarea&&i*j<=p){
						maxarea=i*j;
						p1=i;p2=j;
					}
				}
			}
		}
	}
	cout<<p2<<" "<<p1<<endl;


}


void main(){
	while(1){
		cin>>area>>a>>b;
		if(area==0)break;
		else{
			mysch(area,(double)a/b);		
		}
	}
}

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