Integer Approximation(分治+枚举)

Integer Approximation

https://vjudge.net/problem/POJ-1650

直接暴力枚举每个数,得出最接近的两个整数

#include
#include
#include
#include
#include
#include
using namespace std;
//1 <= L <= 100000
int main()
{
    double num;
    double maxn;
    while(~scanf("%lf%lf",&num,&maxn))
    {
        double left=1;
        double right=1;
        double minn=9999999999;
        double mina=0;
        double minb=0;
        while(left<=maxn&&right<=maxn)
        {
            if(left/right>num)
            {
                if(fabs(left/right-num) 
 

  

你可能感兴趣的:(Integer Approximation(分治+枚举))