結果
問題 | No.894 二種類のバス |
ユーザー | k_6101 |
提出日時 | 2019-12-05 19:42:12 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,668 bytes |
コンパイル時間 | 2,725 ms |
コンパイル使用メモリ | 75,340 KB |
実行使用メモリ | 56,096 KB |
最終ジャッジ日時 | 2023-08-23 12:37:56 |
合計ジャッジ時間 | 6,100 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
55,876 KB |
testcase_01 | AC | 112 ms
55,528 KB |
testcase_02 | AC | 112 ms
55,804 KB |
testcase_03 | AC | 112 ms
55,728 KB |
testcase_04 | AC | 119 ms
55,600 KB |
testcase_05 | AC | 121 ms
55,576 KB |
testcase_06 | AC | 114 ms
55,872 KB |
testcase_07 | AC | 112 ms
55,984 KB |
testcase_08 | WA | - |
testcase_09 | AC | 112 ms
55,996 KB |
testcase_10 | AC | 111 ms
55,292 KB |
testcase_11 | AC | 122 ms
55,500 KB |
testcase_12 | AC | 120 ms
55,592 KB |
testcase_13 | AC | 114 ms
55,836 KB |
testcase_14 | AC | 113 ms
55,876 KB |
testcase_15 | AC | 112 ms
55,708 KB |
testcase_16 | AC | 112 ms
55,760 KB |
testcase_17 | AC | 114 ms
55,908 KB |
testcase_18 | AC | 112 ms
56,096 KB |
testcase_19 | AC | 116 ms
55,856 KB |
ソースコード
import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // 最大公約数の取得 long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } // 最小公倍数の取得 long lcm(long a, long b) { return a / gcd(a, b) * b; } // ================================================================== public void solve() { long T = Long.parseLong(sc.next()); long A = Long.parseLong(sc.next()); long B = Long.parseLong(sc.next()); long ans = T / A - (T % A == 0 ? 1 : 0); // out.println(ans); ans += (T / B - (T % B == 0 ? 1 : 0)); // out.println(ans); long L = lcm(A, B); ans -= (T / L - (T % L == 0 ? 1 : 0)); out.println(ans+1); } // ================================================================== } class PP{ public int key, val; public PP(int key, int val) { this.key = key; this.val = val; } public int getKey() { return key; } public int getVal() { return val; } }