思路:

抄的题解

这叫搜索?

难以理解

我觉得就是枚举+逼近

//By SiriusRen
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,recx,recy,x,y;
int gcd(int a,int b){
return b?gcd(b,a%b):a;
}
int main(){
while(~scanf("%d%d",&x,&y)){
double temp,a,minn=66666.666;
a=(double)x/y;
int n=x,m=y;
x=y=1;
while(x<=32767&&y<=32767){
temp=(double)x/y;
int p=gcd(x,y),dx=x/p,dy=y/p;
if(abs(temp-a)<abs(minn-a)&&(!(dx==n&&dy==m)))
minn=temp,recx=dx,recy=dy;
if(temp<a)x++;
else y++;
}
printf("%d %d\n",recx,recy);
}
}

POJ 3039 搜索??? (逼近)的更多相关文章

  1. catch that cow POJ 3278 搜索

    catch that cow POJ 3278 搜索 题意 原题链接 john想要抓到那只牛,John和牛的位置在数轴上表示为n和k,john有三种移动方式:1. 向前移动一个单位,2. 向后移动一个 ...

  2. [Vjudge][POJ][Tony100K]搜索基础练习 - 全题解

    目录 POJ 1426 POJ 1321 POJ 2718 POJ 3414 POJ 1416 POJ 2362 POJ 3126 POJ 3009 个人整了一些搜索的简单题目,大家可以clone来练 ...

  3. poj 2251 搜索

    Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13923   Accepted: 5424 D ...

  4. poj 1011 搜索减枝

    题目链接:http://poj.org/problem?id=1011 #include<cstdio> #include<cstring> #include<algor ...

  5. 生日蛋糕 POJ - 1190 搜索 数学

    http://poj.org/problem?id=1190 题解:四个剪枝. #define _CRT_SECURE_NO_WARNINGS #include<cstring> #inc ...

  6. poj 2531 搜索剪枝

    Network Saboteur Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u ...

  7. poj 折半搜索

    poj2549 Sumsets 题目链接: http://poj.org/problem?id=2549 题意:给你一个含有n(n<=1000)个数的数列,问这个数列中是否存在四个不同的数a,b ...

  8. poj 3278 搜索

    描述: Farmer John has been informed of the location of a fugitive cow and wants to catch her immediate ...

  9. poj 1129 搜索

    Channel Allocation Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64 ...

随机推荐

  1. LNMP安装部署开源IP管理工具phpipam

    1.数据库 mariadb 安装 //依赖安装 yum install -y apr* autoconf automake bison bzip2 bzip2* compat* \ cpp curl ...

  2. Win 7中开启Telnet功能

    参看以下文章: http://winsystem.ctocio.com.cn/Longhorn/472/8756972.shtml

  3. django-xadmin定制之列表页searchbar placeholder

    环境:xadmin-for-python3 python3.5.2 django1.9.12 列表页的searchbar如果提供的可搜索字段,都没提示哪个字段可搜索,很不友好,本次定制主要增加inpu ...

  4. 怎样只接受固定长度数组为参数 & 数组形参

    注意,对于多维数组的情况.

  5. OpenCv 人脸检測的学习

    近期公司要组织开发分享,可是自己还是新手真的不知道分享啥了,然后看了看前段时间研究过OpenCv,那么就分享他把. openCv就不介绍了,说下人脸检測.事实上是通过openCv里边已经训练好的xml ...

  6. windows開始菜单和任务栏图标显示空白而且点击时候显示项目已被移动或删除

    这几天实验室老常常自己主动断电.这是非常蛋疼的一件事,这不上次断电就出事了.来电后开机,点击任务栏上的程序全都显示为无法打开此项目,该项目已被移动.删除.原因是图标缓存丢失,可能是突然断电引起的,也有 ...

  7. vue2.0 vue-loader

    vue-cli npm install 脚手架: vue-loader 1.0 -> new Vue({ el: '#app', components:{App} }) 2.0-> new ...

  8. .Net商品管理(注释,百度,提问,对比,总结)

    管理控制器 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Sys ...

  9. Android View体系(十)自定义组合控件

    相关文章 Android View体系(一)视图坐标系 Android View体系(二)实现View滑动的六种方法 Android View体系(三)属性动画 Android View体系(四)从源 ...

  10. Redis封装之Hash

    RedisHashService: /// <summary> /// Hash:类似dictionary,通过索引快速定位到指定元素的,耗时均等,跟string的区别在于不用反序列化,直 ...