結果

問題 No.415 ぴょん
ユーザー fal_rndfal_rnd
提出日時 2016-11-17 22:34:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 339 bytes
コンパイル時間 3,640 ms
コンパイル使用メモリ 74,504 KB
実行使用メモリ 41,604 KB
最終ジャッジ日時 2024-04-29 11:46:26
合計ジャッジ時間 5,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,604 KB
testcase_01 AC 119 ms
40,972 KB
testcase_02 AC 116 ms
41,148 KB
testcase_03 AC 116 ms
41,188 KB
testcase_04 AC 112 ms
41,116 KB
testcase_05 AC 119 ms
41,516 KB
testcase_06 AC 119 ms
40,976 KB
testcase_07 AC 106 ms
40,944 KB
testcase_08 AC 121 ms
41,204 KB
testcase_09 AC 109 ms
41,116 KB
testcase_10 AC 121 ms
41,112 KB
testcase_11 AC 120 ms
41,308 KB
testcase_12 AC 110 ms
41,268 KB
testcase_13 AC 107 ms
41,552 KB
testcase_14 AC 126 ms
41,352 KB
testcase_15 AC 119 ms
41,112 KB
testcase_16 AC 112 ms
41,448 KB
testcase_17 AC 121 ms
40,940 KB
testcase_18 AC 119 ms
40,940 KB
testcase_19 AC 112 ms
41,116 KB
testcase_20 AC 123 ms
41,468 KB
testcase_21 AC 106 ms
41,416 KB
testcase_22 AC 121 ms
41,080 KB
testcase_23 AC 126 ms
41,320 KB
testcase_24 AC 119 ms
41,328 KB
testcase_25 AC 112 ms
41,100 KB
testcase_26 AC 110 ms
41,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class A{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		int p = s.nextInt(), j = s.nextInt();
		System.out.println(p/gcd(p,j)-1);
	}
	public static long gcd(long a, long b) {
		long m;
		while(a!=0) {
			m = Math.min(a, b);
			a = Math.max(a, b)%m;
			b = m;
		}
		return b;
	}
}
0