結果

問題 No.8072 Sum of sqrt(x)
ユーザー testestest
提出日時 2020-09-12 16:18:20
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 435 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 61 ms
コンパイル使用メモリ 37,760 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-22 18:55:23
合計ジャッジ時間 63,553 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:13:29: warning: implicit declaration of function 'sqrtl' [-Wimplicit-function-declaration]
   13 |                 ans[index]+=sqrtl(t);
      |                             ^~~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'sqrtl'
    1 | #include<stdio.h>
  +++ |+#include <math.h>
    2 | 
main.c:13:29: warning: incompatible implicit declaration of built-in function 'sqrtl' [-Wbuiltin-declaration-mismatch]
   13 |                 ans[index]+=sqrtl(t);
      |                             ^~~~~
main.c:13:29: note: include '<math.h>' or provide a declaration of 'sqrtl'

ソースコード

diff #
raw source code

#include<stdio.h>

long double ans[20];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		long long t;
		scanf("%lld",&t);
		int index=0;
		for(long long x=1;x<=t;x*=10)index++;
		ans[index]+=sqrtl(t);
		
		long double a=0;
		for(int i=0;i<20;i++)a+=ans[i];
		
		index=0;
		for(long double x=1;x<=a;x*=10)index++;
		char format[20];
		sprintf(format,"%c%c%d%c%c%c",'%','.',17-index,'L','f','\n');
		printf(format,a);
	}
}
0