結果

問題 No.415 ぴょん
ユーザー 37zigen37zigen
提出日時 2016-08-24 17:08:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 448 bytes
コンパイル時間 4,582 ms
コンパイル使用メモリ 71,588 KB
実行使用メモリ 56,184 KB
最終ジャッジ日時 2023-08-11 20:13:14
合計ジャッジ時間 7,687 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,672 KB
testcase_01 AC 123 ms
56,184 KB
testcase_02 AC 122 ms
55,564 KB
testcase_03 AC 121 ms
56,108 KB
testcase_04 AC 121 ms
55,848 KB
testcase_05 AC 124 ms
55,752 KB
testcase_06 AC 121 ms
55,600 KB
testcase_07 AC 122 ms
55,812 KB
testcase_08 AC 123 ms
55,908 KB
testcase_09 AC 122 ms
55,956 KB
testcase_10 AC 123 ms
55,868 KB
testcase_11 AC 124 ms
55,600 KB
testcase_12 AC 124 ms
55,940 KB
testcase_13 AC 126 ms
55,988 KB
testcase_14 AC 123 ms
55,788 KB
testcase_15 AC 125 ms
55,780 KB
testcase_16 AC 124 ms
55,772 KB
testcase_17 AC 124 ms
55,852 KB
testcase_18 AC 125 ms
55,744 KB
testcase_19 AC 123 ms
55,948 KB
testcase_20 AC 123 ms
55,732 KB
testcase_21 AC 125 ms
55,948 KB
testcase_22 AC 125 ms
55,964 KB
testcase_23 AC 125 ms
55,724 KB
testcase_24 AC 124 ms
55,980 KB
testcase_25 AC 124 ms
55,764 KB
testcase_26 AC 125 ms
55,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package No400番台;

import java.util.Scanner;

public class Q415 {
	public static void main(String[] args) {
		new Q415().solver();
	}
	void solver() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long D = sc.nextLong();
		System.out.println(N / gcd(D, N) -1);
	}

	static long gcd(long t1, long t2) {
		if (t1 < t2) {
			long d = t2;
			t2 = t1;
			t1 = d;
		}
		if (t2 == 0)
			return t1;
		return gcd(t2, t1 % t2);
	}

}
0