結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー rurururu
提出日時 2017-06-12 10:27:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 55,696 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 21:30:35
合計ジャッジ時間 1,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 27 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 27 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   10 | main(){
      | ^~~~

ソースコード

diff #

#include <iostream>

using namespace std;

void fibo(unsigned long int);

unsigned long int f1,f2,f11,f22;
const unsigned long int keta=1000000000;

main(){
	unsigned long int N,M;
	unsigned long int F;
	
	//ݒ
	f1=0;f2=1;f11=f22=0;
	
	cin >> N >> M;
	fibo(N);
	F=f22%M;
	F=(f2+F*keta)%M;
	
	cout << F << endl;
	return 0;
}

void fibo(unsigned long int N){
	unsigned long int a,aa;
	for(int i=3;i<=N;i++){
		a=f2+f1;
		aa=f22+f11+a/keta;
		a=a%keta;
		f1=f2;
		f11=f22;
		f2=a;
		f22=aa;
	//	cout<<f22<<f2<<endl;
	}
}
	
0