11 条题解

  • 1
    @ 2025-9-14 16:18:47

    我是 高手 初学者,能AC就行~

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    int main()
    {
    	double a,b,c,x1,x2;
    	cin >> a >> b >> c;
    	if(a == 0 || b*b - 4*a*c < 0)
    		cout << "No answer!";
    	else
    	{
    		x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
    		x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
    		if(x1 == x2)
    			printf("x1=x2=%.5f",x1);
    		else
    		{
    			if(x1 > x2)
    				swap(x1,x2);
    			printf("x1=%.5f;x2=%.5f",x1,x2);
    		}
    	}
    	
    	return 0;
    }
    

    信息

    ID
    876
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    743
    已通过
    201
    上传者