思路:

抄的题解

这叫搜索?

难以理解

我觉得就是枚举+逼近

//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. LOJ #109. 并查集

    内存限制:256 MiB时间限制:2000 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: 匿名 提交提交记录统计讨论 1 测试数据   题目描述 这是一道模板题. 维护一个 nnn 点 ...

  2. php实现自动加载类

    PHP 实现自动加载类:

  3. jquery validate验证规则重用

    当多个控件验证规则相同时,如何避免冗余代码并应用相同规则呢? [1st way. addMethod+addClassRules] 场景:维护学生档案时需要维护父母.监护人.紧急联系人的身份证号码,此 ...

  4. 入门python:《Python编程从入门到实践》中文PDF+英文PDF+代码学习

    入门python推荐学习久负盛名的python入门书籍<Python编程从入门到实践>. 书中涵盖的内容是比较精简的,没有艰深晦涩的概念,最重要的是每个小结都附带有"动手试一试& ...

  5. Ubuntu 环境下的mysql 远程访问,redis 远程访问和设置密码 ,mongo 安装 ,设置用户密码,开启远程访问

    MySQL远程访问 1.编辑mysql配置文件,把其中bind-address = 127.0.0.1注释了 vi /etc/mysql/mysql.conf.d/mysqld.cnf 2.使用roo ...

  6. Maven 工程 POM.XML文件最全详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  7. Maven学习总结(21)——Maven常用的几个核心概念

    在使用Maven的过程中,经常会遇到几个核心的概念,准确的理解这些概念将会有莫大的帮助. 1. POM(Project Object Model)项目对象模型 POM 与 Java 代码实现了解耦,当 ...

  8. 【 Beginning iOS 7 Development《精通iOS7开发》】05 Autorotation and Autosizing

    一.旋转后相对位置不变 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ29nbGVy/font/5a6L5L2T/fontsize/400/fill/I0 ...

  9. CCNP路由实验之九 路由策略

     CCNP路由实验之九 路由策略 路由器在公布与接收路由信息时,可能须要实施一些策略.以便对路由信息进行过滤,比如仅仅接收或公布满足一定条件的路由信息. 一种路由协议可能须要引入其它的路由协议发现 ...

  10. jfinal文件上传与下载

    import com.alibaba.fastjson.JSONObject; import com.jfinal.core.Controller; import com.jfinal.ext.kit ...