結果

問題 No.955 ax^2+bx+c=0
コンテスト
ユーザー ciel
提出日時 2020-02-23 10:57:56
言語 C90
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,804 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 114 ms
コンパイル使用メモリ 28,624 KB
最終ジャッジ日時 2026-02-24 01:04:28
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from main.c:2:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/lib/gcc/current/gcc/x86_64-pc-linux-gnu/15/include/quadmath.h:185:26: error: expected ',' or ';' before '__float128'
  185 | __quadmath_extern_inline __float128
      |                          ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/lib/gcc/current/gcc/x86_64-pc-linux-gnu/15/include/quadmath.h:191:26: error: expected ',' or ';' before '__float128'
  191 | __quadmath_extern_inline __float128
      |                          ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/lib/gcc/current/gcc/x86_64-pc-linux-gnu/15/include/quadmath.h:197:26: error: expected ',' or ';' before '__complex128'
  197 | __quadmath_extern_inline __complex128
      |                          ^~~~~~~~~~~~
main.c:4:1: error: C++ style comments are not allowed in ISO C90
    4 | /// dlfcn.h ///
      | ^
main.c:4:1: note: (this will be reported only once per input file)

ソースコード

diff #
raw source code

#include <stdio.h>
#include <quadmath.h>

/// dlfcn.h ///
#ifdef __cplusplus
extern "C"{
#endif
#if defined(WIN32) || (!defined(__GNUC__) && !defined(__clang__))
	void* LoadLibraryA(const char *x);
	void* GetProcAddress(void *x,const char *y);
	int   FreeLibrary(void *x);
#elif defined(__APPLE__)
	void* dlopen(const char *x,int y);
	void* dlsym(void *x,const char *y);
	int   dlclose(void *x);
	#define LoadLibraryA(s) dlopen(s,2)
	#define GetProcAddress dlsym
	#define FreeLibrary dlclose
#else
	void* __libc_dlopen_mode(const char *x,int y);
	void* __libc_dlsym(void *x,const char *y);
	int   __libc_dlclose(void *x);
	#define LoadLibraryA(s) __libc_dlopen_mode(s,2)
	#define GetProcAddress __libc_dlsym
	#define FreeLibrary __libc_dlclose
#endif
#ifdef __cplusplus
}
#endif

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/lib64/libquadmath.so");
	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;
}
0