結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-26 19:05:02 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 10 ms / 5,000 ms |
コード長 | 1,138 bytes |
コンパイル時間 | 467 ms |
コンパイル使用メモリ | 66,320 KB |
実行使用メモリ | 26,956 KB |
最終ジャッジ日時 | 2024-10-04 09:41:02 |
合計ジャッジ時間 | 1,271 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#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[1000001][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;}