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 |
代码#include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; bool cmp(int a,int b){ return a>b; } int vis[51000]; int s[50010]; int j; void Set(){ cle(vis); vis[1]=1; j=0; for(int i=2;i<=30000;i++){ if(!vis[i]){ s[++j]=i; for(int j=i+i;j<=50000;j+=i) vis[j]=1; } } } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int m,a,b,p,q; Set(); while(cin>>m>>a>>b){ if(m==0&&a==0&&b==0)break; int ap=2,aq=2; int ans=-INF; for(int i=1;i<=j;i++){ if(s[i]>m)break; for(int k=i;k<=j;k++){ int tmp=s[i]*s[k]; if(tmp>m)break; if(a*s[k]>b*s[i])break; if(tmp<=ans)continue; ans=tmp; ap=s[i]; aq=s[k]; } } printf("%d %d\n",ap,aq); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator