結果
問題 | No.314 ケンケンパ |
ユーザー |
|
提出日時 | 2015-12-12 17:42:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 1,000 ms |
コード長 | 958 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 65,148 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-15 08:47:08 |
合計ジャッジ時間 | 1,408 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream>#include <cstring>#include <algorithm>#include <limits.h>#include <cmath>#include <time.h>#include <functional>#define REP(i,a,b) for(i=a;i<b;i++)#define rep(i,n) REP(i,0,n)#define MOD1 1000000007;using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;/* ここからが本編 *//* */ull dp[1000005];// dp[i]はiがパーで終わる奴void solve(int n){int i;dp[0] = 1; //便宜上dp[1] = 0;dp[2] = 1;dp[3] = 1;dp[4] = 1;for(i=5;i<n+1;i++) {dp[i] = (dp[i-2] + dp[i-3])%MOD1 ;}}int main(void){int test = 0;int i,j,k,l;int N;ull rep;cin >> N;solve(N);if(test) {for(i=0;i<N+1;i++) {printf("dp[%d] = %llu\n",i,dp[i]);}}if(N > 2) {rep = (dp[N] + dp[N-1] + dp[N-2]) %MOD1;}else {switch(N) {case 2: rep = 2;break;case 1: rep = 1;break;}}cout << rep << endl;return 0;}