結果
| 問題 |
No.554 recurrence formula
|
| コンテスト | |
| ユーザー |
gigime
|
| 提出日時 | 2017-08-11 22:27:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 809 bytes |
| コンパイル時間 | 1,690 ms |
| コンパイル使用メモリ | 165,772 KB |
| 実行使用メモリ | 6,016 KB |
| 最終ジャッジ日時 | 2024-10-12 21:08:41 |
| 合計ジャッジ時間 | 2,184 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;
int N;
const int MAX_N = 100000;
ll accOdd [MAX_N + 17],accEven [MAX_N + 17];
ll A [MAX_N + 17];
const ll MOD = 1e9 + 7;
int main()
{
scanf("%d",&N);
A [1] = 1;
accOdd [2] = 1;
FOR(i,2,N + 1){
if(i % 2 == 0){
A [i] = accOdd [i] * i % MOD;
accOdd [i + 1] = accOdd [i];
accEven [i + 1] = (accEven [i] + A [i]) % MOD;
}
else{
A [i] = accEven [i] * i % MOD;
accOdd [i + 1] = (accOdd [i] + A [i]) % MOD;
accEven [i + 1] = accEven [i];
}
}
printf("%lld\n",A [N]);
return 0;
}
gigime