結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
53,860 KB
testcase_01 AC 120 ms
54,000 KB
testcase_02 AC 115 ms
54,188 KB
testcase_03 AC 128 ms
53,988 KB
testcase_04 AC 117 ms
54,244 KB
testcase_05 AC 128 ms
54,100 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
			tmp2+=tmp;
		}
		System.out.println(tmp2%num[1]);
	}
}
0