結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー |
![]() |
提出日時 | 2017-06-13 15:19:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 637 ms |
コンパイル使用メモリ | 84,888 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 16:56:41 |
合計ジャッジ時間 | 1,619 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
/* -*- coding: utf-8 -*- * * 526.cc: No.526 フィボナッチ数列の第N項をMで割った余りを求める - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ /* typedef */ typedef long long ll; typedef vector<int> vi; typedef queue<int> qi; typedef pair<int,int> pii; /* global variables */ /* subroutines */ /* main */ int main() { int n; ll m; cin >> n >> m; ll f1 = 0, f2 = 1; for (int i = 2; i < n; i++) { ll f3 = (f1 + f2) % m; f1 = f2, f2 = f3; } printf("%lld\n", f2); return 0; }