結果

問題 No.454 逆2乗和
ユーザー ndifix
提出日時 2016-12-07 16:56:18
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 280 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 21,888 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 03:23:20
合計ジャッジ時間 915 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other WA * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:13: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double *’ [-Wformat=]
    9 |     scanf("%f",&x);
      |            ~^  ~~
      |             |  |
      |             |  double *
      |             float *
      |            %lf
main.c:9:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%f",&x);
      |     ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
    double a=1.6449340668482426;
    double x;
    int y;
    int i;
    
    scanf("%f",&x);
    y=x;
    for(i=1; i<=y; i++){
        a-= 1/ (i*i);
    }
    if(x-y>0){
        a-= 1/ (x*x);
    }
    
    printf("%.9f\n",a);
    
    return 0;
}
0