結果

問題 No.2749 随伴関手入門
ユーザー ks2mks2m
提出日時 2024-05-10 23:09:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 75,168 KB
実行使用メモリ 54,468 KB
最終ジャッジ日時 2024-05-10 23:09:26
合計ジャッジ時間 7,279 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,160 KB
testcase_01 AC 129 ms
54,260 KB
testcase_02 AC 128 ms
54,060 KB
testcase_03 AC 131 ms
54,340 KB
testcase_04 AC 129 ms
54,088 KB
testcase_05 AC 129 ms
54,108 KB
testcase_06 AC 118 ms
53,040 KB
testcase_07 AC 128 ms
53,944 KB
testcase_08 AC 118 ms
53,012 KB
testcase_09 AC 134 ms
54,136 KB
testcase_10 AC 131 ms
54,468 KB
testcase_11 AC 132 ms
54,412 KB
testcase_12 AC 131 ms
53,972 KB
testcase_13 AC 131 ms
54,164 KB
testcase_14 AC 132 ms
54,336 KB
testcase_15 AC 131 ms
54,124 KB
testcase_16 AC 129 ms
54,124 KB
testcase_17 AC 133 ms
52,700 KB
testcase_18 AC 132 ms
54,112 KB
testcase_19 AC 119 ms
52,932 KB
testcase_20 AC 119 ms
52,844 KB
testcase_21 AC 132 ms
53,952 KB
testcase_22 AC 130 ms
54,196 KB
testcase_23 AC 115 ms
53,220 KB
testcase_24 AC 126 ms
54,272 KB
testcase_25 AC 139 ms
54,388 KB
testcase_26 AC 132 ms
54,136 KB
testcase_27 AC 128 ms
52,892 KB
testcase_28 AC 117 ms
52,832 KB
testcase_29 AC 129 ms
54,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		if (n == 1) {
			System.out.println(1);
			return;
		}

		BigInteger nb = BigInteger.valueOf(n);
		BigInteger a = BigInteger.ONE;
		BigInteger b = BigInteger.ONE;
		int i = 2;
		while (true) {
			i++;
			BigInteger c = a.add(b);
			if (c.mod(nb).compareTo(BigInteger.ZERO) == 0) {
				System.out.println(i);
				return;
			}
			a = b;
			b = c;
		}
	}
}
0