记录编号 545533 评测结果 AAAAAAAAAA
题目名称 [NOIP 2014PJ]比例简化 最终得分 100
用户昵称 Gravatar夜莺 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2019-10-30 20:02:10 内存使用 0.00 MiB
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int pd[101]={0,1,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0};
int ss(int x,int y){
	float z;
	z=x%y;
	while(z!=0){
		x=y;
		y=z;
		z=x%y;
	}
	if(y==1)return 1;
	return 0;
}
int Main(){
	float a,b,aa,bb,ago,next,minn=9999999;
	int n;
	freopen("ratio.in","r",stdin);
	freopen("ratio.out","w",stdout);
	cin>>a>>b>>n;
	bool e=0;
	if(a<b)e=1;
	ago=a/b;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++){
			if((pd[i]==1&&pd[j]==1)||abs(i-j)==1||ss(i,j)==1){
				float jj=j,ii=i;
				if(e==1)swap(jj,ii);
				next=jj/ii;
				if(next>=ago)
					if(next-ago<minn){
						minn=next-ago;
						aa=jj;
						bb=ii;
					}
			}
		}
	cout<<aa<<' '<<bb;
}
int uu=Main();
int main(){;}