結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー |
![]() |
提出日時 | 2017-12-31 18:05:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 451 bytes |
コンパイル時間 | 790 ms |
コンパイル使用メモリ | 75,096 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 15:31:24 |
合計ジャッジ時間 | 1,858 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
ソースコード
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <map> #include <string> using namespace std; void solve(); int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); } void solve() { int n,m; cin >> n >> m; int a1 = 0 % m; int a2 = 1 % m; for(int i = 3; i <= n; i++) { int tmp = (a1 + a2) % m; a1 = a2; a2 = tmp; } cout << a2 << endl; }