Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const string FNAME = "data";
- ifstream fin(FNAME + ".in");
- ofstream fout(FNAME + ".out");
- constexpr int MOD = 1'000'000'007;//'
- int main() {
- int n;
- fin >> n;
- int dp[3] = {1, 3};
- for (int i = 3; i <= n; i++) {
- dp[2] = (2LL * dp[0] % MOD + dp[1]) % MOD;
- dp[0] = dp[1];
- dp[1] = dp[2];
- }
- fout << dp[2] << endl;
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement