結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-26 19:04:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,137 bytes |
コンパイル時間 | 476 ms |
コンパイル使用メモリ | 66,240 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 09:40:56 |
合計ジャッジ時間 | 2,615 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 RE * 8 |
ソースコード
#include <iostream> #include <cstdio> #include <algorithm> #include <cstdlib> #include <cstring> #include <cmath> #include <vector> #include <queue> using namespace std; #define FOR(i,a,b) for (ll i = (a); i < (b); i++) #define REP(i,n) FOR(i,0,n) long gcd(long a, long b){ if (a%b==0){ return b; } else{ return gcd(b,a%b); } } long lcm(long a, long b){ return (a*b) / gcd(a,b); } template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; ll c[100001][3]; int main(){ ll n; cin >> n; c[0][0] = 0; c[0][1] = 0; c[0][2] = 0; c[1][0] = 1; c[1][1] = 0; c[1][2] = 0; c[2][0] = 0; c[2][1] = 1; c[2][2] = 0; c[3][0] = 1; c[3][1] = 1; c[3][2] = 1; FOR(i,4,n+1){ c[i][0] = (c[i-1][1] + c[i-1][2])%MOD; c[i][1] = (c[i-2][0] + c[i-2][2])%MOD; c[i][2] = (c[i-3][0] + c[i-3][1])%MOD; } printf("%lld\n", (c[n][0]+c[n][1]+c[n][2])%MOD); return 0; }