結果
問題 | No.554 recurrence formula |
ユーザー |
![]() |
提出日時 | 2017-08-11 22:39:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 1,473 ms |
コンパイル使用メモリ | 166,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 21:21:42 |
合計ジャッジ時間 | 2,144 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 signed main(){ int n; cin>>n; if(n==1){ cout<<1<<endl; return 0; } int a=1,b=0; int now=1; for(int i=1;i<=n;i++){ if(!(i%2)){ now=i*a; now%=MOD; b+=now; }else{ now=i*b; now%=MOD; a+=now; } a%=MOD; b%=MOD; } cout<<now<<endl; return 0; }