結果
| 問題 | 
                            No.955 ax^2+bx+c=0
                             | 
                    
| コンテスト | |
| ユーザー | 
                             bal4u
                         | 
                    
| 提出日時 | 2019-12-18 16:44:42 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 833 bytes | 
| コンパイル時間 | 220 ms | 
| コンパイル使用メモリ | 32,000 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-07 00:51:39 | 
| 合計ジャッジ時間 | 2,302 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 120 WA * 2 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d%d%d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
// yuki 955 ax^2+bx+c=0
// 2019.12.18 bal4u
#include <stdio.h>
#include <math.h>
typedef long long ll;
#define ZERO(x)  (fabsl(x)<=1e-16)
int main()
{
	int a, b, c;
	long double x1, x2;
	scanf("%d%d%d", &a, &b, &c);
	if (a == 0) {
		if (b == 0 && c == 0) puts("-1");
		else if (b == 0) puts("0");
		else {
			puts("1");
			printf("%.16lf\n", -(double)c/b);
		}
	} else {
		ll d = (ll)b*b - 4*(ll)a*c;
		if (d < 0) puts("0");
		else if (d == 0) {
			puts("1");
			printf("%.16lf\n", -(double)b/(2*(ll)a));
		} else {
			long double t = sqrtl((long double)d);
			puts("2");
			x1 = (-b-t)/(2*(ll)a), x2 = (-b+t)/(2*(ll)a);
			t = a*x1*x1 + b*x1 + c;
			if (!ZERO(t)) x1 = x2;
			x2 = (long double)c/a/x1;
			if (x1 <= x2) printf("%.16Lf\n%.16Lf\n", x1, x2);
			else          printf("%.16Lf\n%.16Lf\n", x2, x1);
		}
	}
	return 0;
}
            
            
            
        
            
bal4u