結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-18 03:14:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 678 bytes |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 32,640 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 00:21:24 |
| 合計ジャッジ時間 | 2,299 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 48 WA * 74 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:60: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
20 | if (b * b - 4 * a * c > 0) printf("2\n%.20lf\n%.20lf\n", (double) (-tb - sqrt(tb * tb - 4 * ta * tc))/ (ta * 2), (double) (-tb + sqrt(tb * tb - 4 * ta * tc))/ (ta * 2));
| ~~~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| double long double
| %.20Lf
main.cpp:20:68: warning: format ‘%lf’ expects argument of type ‘double’, but argument 3 has type ‘long double’ [-Wformat=]
20 | if (b * b - 4 * a * c > 0) printf("2\n%.20lf\n%.20lf\n", (double) (-tb - sqrt(tb * tb - 4 * ta * tc))/ (ta * 2), (double) (-tb + sqrt(tb * tb - 4 * ta * tc))/ (ta * 2));
| ~~~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| double long double
| %.20Lf
main.cpp:22:38: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
22 | else printf("1\n%.20lf\n", (d
ソースコード
#include <stdio.h>
#include <math.h>
int main() {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a == 0) {
if (b == 0) {
if (c == 0) printf("-1\n");
else printf("0\n");
}
else printf("1\n%.20lf\n", (double)((long double)c / (long double)b));
}
else {
if (a < 0) {
a = -a;
b = -b;
c = -c;
}
long double ta(a), tb(b), tc(c);
if (b * b - 4 * a * c > 0) printf("2\n%.20lf\n%.20lf\n", (double) (-tb - sqrt(tb * tb - 4 * ta * tc))/ (ta * 2), (double) (-tb + sqrt(tb * tb - 4 * ta * tc))/ (ta * 2));
else if (b * b - 4 * a * c < 0) printf("0\n");
else printf("1\n%.20lf\n", (double) -tb / (ta * 2));
}
}