結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー |
![]() |
提出日時 | 2020-05-06 22:53:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 301 bytes |
コンパイル時間 | 484 ms |
コンパイル使用メモリ | 68,356 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 09:11:30 |
合計ジャッジ時間 | 1,389 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; ll n,m; int main() { cin >> n >> m; ll a = 0, b = 1; for (ll i = 3; i <= n; i++) { ll c = (a + b) % m; a = b; b = c; } cout << b << endl; return 0; }