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

代码

Posted by _AVG at 2015-08-10 14:55:32 on Problem 1411
#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:
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