結果

問題 No.415 ぴょん
ユーザー takeya_okino
提出日時 2017-07-09 11:23:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 402 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 73,896 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-11-18 14:54:28
合計ジャッジ時間 8,842 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

  public static long gcd(long a, long b) {
    if(b == 0) return a;
    long M = Math.max(a, b);
    long m = Math.min(a, b);
    return gcd(m, M % m);
  }
}
0