POJ 3039 搜索??? (逼近)
2016-10-27 19:54
246 查看
思路:
抄的题解
这叫搜索?
难以理解
我觉得就是枚举+逼近
//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 搜索??? (逼近)
- poj 3039 Close Encounter “追赶法”搜索
- poj 1759 Garland (二分搜索之其他)
- poj 2976(01分数规划搜索+二分答案)
- poj 3278 Catch That Cow 搜索
- 枚举库函数搜索:POJ2718--Smallest Difference(解二)
- poj 1321 棋盘问题(简单搜索)
- poj1426 Find The Multiple 简单搜索
- POJ-1175:Starry Night(搜索+hash)
- kuangbin专题一 简单搜索 E,POJ 1426 Find The Multiple
- poj 3009 Curling 2.0-----搜索
- poj 3126 Prime Path([kuangbin带你飞]专题一 简单搜索)
- poj1163 【记忆化搜索·水】
- poj 1085 Triangle War 1568 Find the Winning Move 极大极小搜索 alpha-beta剪枝
- [kuangbin带你飞]专题1 简单搜索 K - 迷宫问题 POJ - 3984
- 搜索--poj 2386 Lake Counting
- POJ 1753 Flip Game 暴力搜索(dfs加枚举)
- POJ - 3278 Catch That Cow (搜索)
- poj 搜索题目(转)
- POJ 2329 (暴力+搜索bfs)