結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-22 20:32:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 357 bytes |
| コンパイル時間 | 1,632 ms |
| コンパイル使用メモリ | 157,156 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 17:53:19 |
| 合計ジャッジ時間 | 2,534 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘long long int func(long long int)’:
main.cpp:13:17: warning: ‘temp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
13 | return temp % m;
| ^
main.cpp: In function ‘int main()’:
main.cpp:13:17: warning: ‘temp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
13 | return temp % m;
| ^
main.cpp:7:33: note: ‘temp’ was declared here
7 | long long num1 = 1, num2 = 1, temp;
| ^~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long func(long long a) {
long long num1 = 1, num2 = 1, temp;
for(int i = 1; i < a-2; i++) {
temp = num1 + num2;
num1 = num2;
num2 = temp;
}
return temp % m;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
cout << func(n) << endl;
}