結果
問題 |
No.554 recurrence formula
|
ユーザー |
|
提出日時 | 2018-06-29 20:18:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 1,563 ms |
コンパイル使用メモリ | 169,092 KB |
実行使用メモリ | 15,520 KB |
最終ジャッジ日時 | 2024-06-30 23:53:20 |
合計ジャッジ時間 | 5,753 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 1 TLE * 1 -- * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define fastcin {\ cin.tie(0);\ ios::sync_with_stdio(false);\ } #define MOD 1000000007 typedef long long ll; typedef vector<ll> vll; vll a(100010); void make_a(ll n) { ll sum = 0; if(n&1) { for(int i=n-1; i>=2; i-=2) { if(a[i]==0) make_a(i); sum += a[i]; sum %= MOD; } } else { for(int i=n-1; i>=1; i-=2) { if(a[i]==0) make_a(i); sum += a[i]; sum %= MOD; } } a[n] = n*sum % MOD; } int main() { fastcin; int n; cin >> n; a[1] = 1; make_a(n); cout << a[n] << endl; return 0; }