結果

問題 No.314 ケンケンパ
ユーザー treeonetreeone
提出日時 2015-12-26 18:56:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 737 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 70,264 KB
実行使用メモリ 11,432 KB
最終ジャッジ日時 2023-10-19 04:20:01
合計ジャッジ時間 1,397 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

lint a[1000001]={};
lint mod=1e9+7;

int main(){
	int n;
	a[1]=0; a[2]=1; a[3]=1;
	cin>>n;
	rep(i,4,n){
		a[i]=(a[i-2]+a[i-3])%mod;
	}
	if(n==1) o(1);
	else if(n==2||n==3) o(2);
	else{
		lint ans=(a[n-1]+2*a[n-2]+a[n-3])%mod;
		o(ans);
	}
}
0