4 条题解

  • 1
    @ 2025-10-23 0:13:23

    数据改了 debug半天发现是a=0时变为线性关系也需要输出两个小数而不是一个,,, 下面的题解应该都是数据没改的时候的 用不了了 我重写一个

    #include<iostream>
    #include<stdio.h>
    #include<string>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    double a,b,c;
    int main()
    {
    	scanf("%lf %lf %lf",&a,&b,&c);
    	if(a==0){
    		if(b==0){
    			printf("no solution");
    		}
    		else printf("%.6lf %.6lf",-(c/b),-(c/b));	
    	}
    	else {
    		double dd=b*b-4*a*c;
    		if(dd<0){
    			printf("no solution");
    		}
    		else{
    			double x1=((-b)-sqrt(dd))/(2*a);
    			double x2=((-b)+sqrt(dd))/(2*a);
    			if(x1<x2)	printf("%.6lf %.6lf",x1,x2);
    			else printf("%.6lf %.6lf",x2,x1);			
    		}
    	}
    	return 0;
    }
    

    信息

    ID
    22
    时间
    1000ms
    内存
    512MiB
    难度
    3
    标签
    递交数
    2070
    已通过
    74
    上传者