結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー gu_21816943gu_21816943
提出日時 2017-06-26 01:22:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 439 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 74,496 KB
実行使用メモリ 54,308 KB
最終ジャッジ日時 2024-04-14 23:52:50
合計ジャッジ時間 4,603 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
54,056 KB
testcase_01 AC 122 ms
54,156 KB
testcase_02 AC 128 ms
53,912 KB
testcase_03 AC 120 ms
54,168 KB
testcase_04 AC 119 ms
54,228 KB
testcase_05 AC 118 ms
53,856 KB
testcase_06 AC 128 ms
54,192 KB
testcase_07 AC 128 ms
54,280 KB
testcase_08 AC 125 ms
54,228 KB
testcase_09 AC 129 ms
53,908 KB
testcase_10 AC 142 ms
54,308 KB
testcase_11 WA -
testcase_12 AC 182 ms
54,012 KB
testcase_13 WA -
testcase_14 AC 183 ms
54,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str=sc.nextLine().split(" ");
		int[] num=new int[2];
		num[0]=Integer.parseInt(str[0]);
		num[1]=Integer.parseInt(str[1]);
		sc.close();
		int tmp1=0,tmp2=1;
		int count=2;
		while(count++<num[0]){
			int tmp=tmp1;
			tmp1=tmp2%num[1];
			tmp2=(tmp2+tmp)%num[1];
		}
		System.out.println(tmp2%num[1]);
	}
}
0