結果
問題 |
No.53 悪の漸化式
|
ユーザー |
![]() |
提出日時 | 2014-10-31 00:00:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 63,936 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 14:47:49 |
合計ジャッジ時間 | 1,468 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | int n;scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:29:15: warning: ‘a2’ may be used uninitialized in this function [-Wmaybe-uninitialized] 29 | printf("%0.10f\n",a2/(double)100000); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <iostream> #include <vector> using namespace std; int main(){ int n;scanf("%d",&n); double a=400000,a1=300000,a2; if(n==0){ printf("4\n");return 0; } else if(n==1){ printf("3\n");return 0; } for(int i=2;i<=n;i++){ a2=(19*a1-12.0*a)/4.0; a=a1; a1=a2; if(a2<(double)1e-9){ a2=0; break; } } printf("%0.10f\n",a2/(double)100000); return 0; if(a2==0)printf("0\n"); else printf("%0.10f\n",a2); //else printf("%0.10f\n",a2); return 0; }