这是什么玄学bug
查看原帖
这是什么玄学bug
302569
Beyond_Problem楼主2021/1/13 15:01

已知第二个测试点输入数据为

1 -4.65 2.25 1.4

输出数据中,应有4.00

经测试 当i=4.00时ans=0

但没有4.00的输出

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

//rt
double a, b, c, d;


int main ( )
{
    cin>> a>> b>> c>> d;

    for ( double i = -100.00; i <= 100.00; i += 0.01)
    {
        double ans = a * i * i * i + b * i * i + c * i + d;    
        if ( ans <= 1e-10 && ans >= -1e-10)
        {
            printf ( "%.2f ", i);
            i += 1.0;
        }
    }

    printf ( "\n");
    return 0;
}
2021/1/13 15:01
加载中...