結果
| 問題 | No.3253 Banned Product |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-20 22:41:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 1,735 ms |
| コンパイル使用メモリ | 194,612 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-11-20 22:41:30 |
| 合計ジャッジ時間 | 2,153 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
redo:
if (n == k) {
cout << "-1\n";
continue;
}
// This is the CORRECT lower bound: (n-1)/k + 1
// Any number with all factors <= k must have a divisor in this range
for (int i = (n - 1) / k + 1; i * i <= n; i++) {
if (n % i == 0) {
n--;
goto redo;
}
}
cout << n << "\n";
}
return 0;
}
vjudge1