結果

問題 No.415 ぴょん
ユーザー nCk_cvnCk_cv
提出日時 2016-08-27 16:20:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 406 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 74,732 KB
実行使用メモリ 41,556 KB
最終ジャッジ日時 2024-04-29 11:39:44
合計ジャッジ時間 6,949 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
40,960 KB
testcase_01 AC 133 ms
41,520 KB
testcase_02 AC 133 ms
41,320 KB
testcase_03 AC 130 ms
40,924 KB
testcase_04 AC 132 ms
41,316 KB
testcase_05 AC 132 ms
41,056 KB
testcase_06 AC 129 ms
41,324 KB
testcase_07 AC 128 ms
41,556 KB
testcase_08 AC 129 ms
41,496 KB
testcase_09 AC 132 ms
41,224 KB
testcase_10 AC 128 ms
41,228 KB
testcase_11 AC 122 ms
40,268 KB
testcase_12 AC 129 ms
41,268 KB
testcase_13 AC 117 ms
41,004 KB
testcase_14 AC 133 ms
41,344 KB
testcase_15 AC 127 ms
41,304 KB
testcase_16 AC 132 ms
41,356 KB
testcase_17 AC 132 ms
41,052 KB
testcase_18 AC 132 ms
41,292 KB
testcase_19 AC 131 ms
41,540 KB
testcase_20 AC 117 ms
40,264 KB
testcase_21 AC 130 ms
41,384 KB
testcase_22 AC 131 ms
40,964 KB
testcase_23 AC 131 ms
41,496 KB
testcase_24 AC 130 ms
41,376 KB
testcase_25 AC 125 ms
41,016 KB
testcase_26 AC 123 ms
40,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			long N = sc.nextInt();
			long D = sc.nextInt();
			long ans = 0;
			long gcd = gcd(N,D);
			N *= D / gcd;
			
			System.out.println(N / D - 1);
			
		}
		static long gcd(long a, long b) {
			if(a < b) return gcd(b,a);
			if(b == 0) return a;
			return gcd(b, a % b);
		}
}
0