結果
問題 |
No.53 悪の漸化式
|
ユーザー |
![]() |
提出日時 | 2014-10-30 23:39:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 540 bytes |
コンパイル時間 | 684 ms |
コンパイル使用メモリ | 64,440 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 14:43:43 |
合計ジャッジ時間 | 1,421 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 6 |
コンパイルメッセージ
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); | ~~~~~^~~~~~~~~
ソースコード
#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=4,a1=3,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/4.0*a1-3.0*a); a=a1; a1=a2; if(a2<=(double)1e-9){ a2=0; break; } } if(a2!=0&&a2>1.0)printf("%f\n",a2); if(a2!=0)printf("%0.10f\n",a2); else printf("%f\n",a2); return 0; }