結果

問題 No.53 悪の漸化式
ユーザー ei1333ei1333
提出日時 2014-11-06 17:25:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,306 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 144,540 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 01:38:41
合計ジャッジ時間 2,430 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
 
typedef long long int64;
const int INF = 1 << 30;


//A0: 4
//A1: 3
//An = (19Ak-1 - 12Ak-2) / 4

double dp[101];
double rec(int idx){
  if(dp[idx] != -1) return dp[idx];
  if(idx <= 1) return 3 + (idx == 0);
  else return( dp[idx] = (19 * rec( idx - 1) - 12 * rec( idx - 2)) / 4.0);
}

int main(){
  int N;
  fill_n( dp, 101, -1);
  cin >> N;
  cout << fixed << setprecision(10) << rec(N) << endl;
}
0