Created
July 4, 2013 16:15
-
-
Save Leko/5928882 to your computer and use it in GitHub Desktop.
AOJ 0168 Kannondou http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0168
漸化式が問題文に書いてあるのでそれをメモ化して取り出すだけ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#define REP(i, n) for ( int i = 0; i < n; i++ ) | |
using namespace std; | |
int main() { | |
int n; | |
vector<int> open(30); | |
open[0] = 1; | |
open[1] = 2; | |
open[2] = 4; | |
for ( int i = 3; i < 30; i++ ) { | |
open[i] = open[i-1] + open[i-2] + open[i-3]; | |
// cout << i << ":" << open[i] << endl; | |
} | |
while(cin >>n, n) { | |
n -= 1; // 添字に合わせる | |
cout << (open[n]/10/365)+1 << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment