結果
| 問題 |
No.3253 Banned Product
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2025-09-05 21:32:53 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 639 bytes |
| コンパイル時間 | 4,184 ms |
| コンパイル使用メモリ | 85,236 KB |
| 実行使用メモリ | 46,904 KB |
| 最終ジャッジ日時 | 2025-09-05 21:32:59 |
| 合計ジャッジ時間 | 4,603 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
label:
for (int z = 0; z < t; z++) {
int n = sc.nextInt();
int k = sc.nextInt();
if (n <= k) {
System.out.println(-1);
continue;
}
for (int v = n; v > k; v--) {
boolean flg = false;
for (int i = 2; i <= k && i * i <= v; i++) {
if (v % i == 0 && v / i <= k) {
flg = true;
break;
}
}
if (!flg) {
System.out.println(v);
continue label;
}
}
System.out.println(-1);
}
sc.close();
}
}
ks2m