結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー dnishdnish
提出日時 2017-06-10 17:42:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 272 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 166,256 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:33:38
合計ジャッジ時間 2,252 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:3:22: warning: 'a3' may be used uninitialized [-Wmaybe-uninitialized]
    3 | #define p(s) cout<<(s)<<endl
      |                      ^
main.cpp:11:12: note: 'a3' was declared here
   11 |         ll a3;
      |            ^~

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;

int main() {
	ll n,m;
	cin>>n>>m;
	ll a1=0,a2=1;
	ll a3;
	REP(i,0,n-2){
		a3=a2+a1;
		a1=a2;
		a2=a3;
	}
	p(a3%m);
	return 0;
}
0