結果
| 問題 |
No.53 悪の漸化式
|
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2014-10-30 23:50:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 530 bytes |
| コンパイル時間 | 648 ms |
| コンパイル使用メモリ | 64,204 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 14:46:51 |
| 合計ジャッジ時間 | 1,394 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 3 |
コンパイルメッセージ
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*a1-12.0*a)/4.0;
a=a1;
a1=a2;
if(a2<(double)1e-9){
a2=0;
break;
}
}
if(a2==0)printf("0\n");
else printf("%0.10f\n",a2);
//else printf("%0.10f\n",a2);
return 0;
}
184