| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么TLE??高手来解释一下:#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator