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

What's wrong?.........

Posted by ice_lemon at 2006-08-18 11:52:24 on Problem 1411
#include <cstdlib>
#include <iostream>

using namespace std;
int prime[350],prime2[150];
int main()
{   
    int i,j,m,a,b,p,q,num,max;
    double f1,f2;
     memset(prime,0,sizeof(prime));
     memset(prime2,0,sizeof(prime2));
     prime[1]=0;
     for(i=2;i<350;i++)
      for(j=i;i*j<350;j++)
         prime[i*j]=1;
        
        
        for(i=2,j=0;i<350;i++)
        if(prime[i]==0) prime2[j++]=i;
        num=j;
       
    while(1)
    {
          cin>>m>>a>>b;
          if(m==0&&a==0&&b==0) break;
          max=0;
          p=0;
          q=0;
            for(i=0;i<num;i++)
              for(j=i;j<num;j++)
              {   
                  if(prime2[i]*prime2[j]>m) break;
                  
                  f1=1.0*a/b;
                  f2=1.0*prime2[i]/prime2[j];
                 
                  if(f2<f1 ) break;
                  
                 if(prime2[i]*prime2[j]>max)
                { 
                 max=prime2[i]*prime2[j];
                 p=i;
                 q=j;
                 
                }
               
               }
               
          cout<<prime2[p]<<" "<<prime2[q]<<endl;
            
    }
    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