結果

問題 No.53 悪の漸化式
ユーザー ei1333ei1333
提出日時 2014-11-06 17:25:56
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,306 bytes
コンパイル時間 1,345 ms
コンパイル使用メモリ 159,852 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-31 06:19:48
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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