結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-04 22:59:40 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,195 bytes |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 24,064 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-29 17:33:20 |
| 合計ジャッジ時間 | 2,758 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 122 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:25:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%lld%lld%lld",&a,&b,&c);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <quadmath.h>
#include <dlfcn.h>
#define LoadLibraryA(s) dlopen(s,2)
#define GetProcAddress dlsym
#define FreeLibrary dlclose
typedef __float128 (*type_sqrtq)(__float128);
typedef int (*type_quadmath_snprintf)(char *s, size_t size, const char *format, ...);
type_sqrtq mysqrtq;
type_quadmath_snprintf myquadmath_snprintf;
char buf[99];
int main(){
//void *H=LoadLibraryA("/usr/local/lib/gcc/9/libquadmath.dylib");
void *H=LoadLibraryA("/usr/lib/x86_64-linux-gnu/libquadmath.so.0");
mysqrtq=(type_sqrtq)GetProcAddress(H,"sqrtq");
myquadmath_snprintf=(type_quadmath_snprintf)GetProcAddress(H,"quadmath_snprintf");
int T;
long long a,b,c;
__float128 d;
//for(scanf("%d",&T);T--;){
scanf("%lld%lld%lld",&a,&b,&c);
if(!a){
if(!b)puts(c?"0":"-1");
else printf("1\n%.12Lf\n",-c*1.0L/b);
}else{
if(a<0)a=-a,b=-b,c=-c;
__float128 _a=a,_b=b,_c=c;
d=_b*_b-4.0Q*_a*_c;
if(d<0)puts("0");
else if(d==0)printf("1\n%.12Lf\n",-b/2.0L/a);
else{
puts("2");
myquadmath_snprintf(buf,99,"%.12Qf",(-_b-mysqrtq(d))/2/_a);
puts(buf);
myquadmath_snprintf(buf,99,"%.12Qf",(-_b+mysqrtq(d))/2/_a);
puts(buf);
}
}
//}
return 0;
}