結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー RIGIHRIGIH
提出日時 2017-06-23 17:09:30
言語 C++11
(gcc 11.4.0)
結果
OLE  
実行時間 -
コード長 215 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 53,796 KB
実行使用メモリ 10,400 KB
最終ジャッジ日時 2024-04-14 06:58:48
合計ジャッジ時間 7,130 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 OLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   17 |         printf("%d\n",c);
      |                 ~^    ~
      |                  |    |
      |                  int  long int
      |                 %ld

ソースコード

diff #

#include<stdio.h>
#include <iostream>
using namespace std;


int main(){
	while (1){

	long n,m;
	cin>>n>>m;
	long a=0,b=1,c,i;
	for(i=0;i<n-2;i++){
		c=(a+b)%m;
		a=b;
		b=c;
	}
	printf("%d\n",c);


	}
	return 0;
}
0