結果
問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
ユーザー |
|
提出日時 | 2022-12-30 23:03:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 453 bytes |
コンパイル時間 | 1,389 ms |
コンパイル使用メモリ | 165,260 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-25 21:32:56 |
合計ジャッジ時間 | 2,273 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:22:11: warning: 'pre' may be used uninitialized [-Wmaybe-uninitialized] 22 | cout << pre << endl; | ^~~ main.cpp:12:7: note: 'pre' was declared here 12 | int pre, prepre; | ^~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<n; ++i) using namespace std; using std::abs; using P = pair<long long, long long>; typedef long long ll; const ll INF = 100000000000000000LL; int main(void) { int N, M; cin >> N >> M; int pre, prepre; rep(i, N) { if(i == 0) prepre = 0; else if(i == 1) pre = 1; else { int tmp = (prepre + pre) % M; prepre = pre; pre = tmp; } } cout << pre << endl; }