結果
問題 |
No.176 2種類の切手
|
ユーザー |
![]() |
提出日時 | 2020-01-14 18:21:11 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 729 bytes |
コンパイル時間 | 2,406 ms |
コンパイル使用メモリ | 79,036 KB |
実行使用メモリ | 83,028 KB |
最終ジャッジ日時 | 2024-12-26 01:11:05 |
合計ジャッジ時間 | 10,058 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 2 TLE * 1 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextInt(); long b = sc.nextInt(); long t = sc.nextInt(); long lcm = a / gcd(a, b) * b; long total = t % lcm; long min = Long.MAX_VALUE; for (int i = 0; i * a < total; i++) { min = Math.min(min, (total - i * a + b - 1) / b * b - total + i * a); } min = Math.min(min, (total + a - 1) / a * a - total); System.out.println(t + min); } static long gcd(long x, long y) { if (x % y == 0) { return y; } else { return gcd(y, x % y); } } }