結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー |
|
提出日時 | 2024-03-30 20:41:11 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 345 bytes |
コンパイル時間 | 3,793 ms |
コンパイル使用メモリ | 261,060 KB |
実行使用メモリ | 42,572 KB |
最終ジャッジ日時 | 2024-09-30 17:44:34 |
合計ジャッジ時間 | 4,753 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; ll N, M; ll Fib[5050505]; int main() { cin >> N >> M; Fib[1] = 0; Fib[2] = 1; for (ll i = 3; i <= N; i++) { Fib[i] = (Fib[i - 1] + Fib[i - 2]) % M; } cout << Fib[N] << endl; return 0; }