結果
問題 |
No.554 recurrence formula
|
ユーザー |
|
提出日時 | 2017-11-27 20:07:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 422 bytes |
コンパイル時間 | 557 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 11:23:09 |
合計ジャッジ時間 | 999 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include<cstdio> #define MOD 1000000007 typedef long long int lli; int main(void) { int n; scanf("%d",&n); lli e=0, o=1, a=1; for(int i=2; i<=n; i++) { if(i%2) { a=(i*e) % MOD; a%=MOD; o+=a; o%= MOD; } else { a=(i*o) % MOD; a%=MOD; e+=a; e%= MOD; } } printf("%lld\n", a%MOD); }