結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-12-21 01:23:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,101 bytes |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 85,476 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-18 06:27:14 |
| 合計ジャッジ時間 | 3,191 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 78 WA * 44 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d%d%d", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 955.cc: No.955 ax^2+bx+c=0 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
/* typedef */
typedef long double ld;
/* global variables */
/* subroutines */
/* main */
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a == 0) {
if (b == 0)
printf("%d\n", (c == 0) ? -1 : 0);
else
printf("1\n%25Lf\n", (ld)c / b);
}
else {
ld fa = a, fb = b, fc = c;
ld dd = fb * fb - 4 * fa * fc;
if (dd > 0.0) {
ld d = sqrtl(dd);
ld x0 = (-fb - d) / (fa * 2);
ld x1 = (-fb + d) / (fa * 2);
if (x0 > x1) swap(x0, x1);
printf("2\n%.25Lf\n%.25Lf\n", x0, x1);
}
else if (dd == 0.0)
printf("1\n%.25Lf\n", -fb / (fa * 2));
else
puts("0");
}
return 0;
}
tnakao0123