結果
| 問題 |
No.3253 Banned Product
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 22:02:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,129 bytes |
| コンパイル時間 | 2,368 ms |
| コンパイル使用メモリ | 194,616 KB |
| 実行使用メモリ | 15,944 KB |
| 最終ジャッジ日時 | 2025-09-05 22:02:34 |
| 合計ジャッジ時間 | 5,680 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 TLE * 1 -- * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:17: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | freopen (TASKNAME ".inp", "r", stdin);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:51:17: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | freopen (TASKNAME ".out", "w", stdout);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>
using namespace std;
const int N = 5 + 1e5;
const int inf = 7 + 1e9;
void solve() {
int n, k;
cin >> n >> k;
if (n == k) {
cout << "-1\n";
return;
}
ll spr = (ll)k * k;
if (spr < n) {
cout << n << '\n';
return;
}
while (n > 0) {
int ok = 1;
for (int i = 1; i * i <= n, i <= k; i ++)
if (n % i == 0) {
int x = n / i;
if (x <= k) {
ok = 0;
break;
}
}
if (ok) {
cout << n << '\n';
return;
}
n --;
}
cout << "-1\n";
}
int main() {
#define TASKNAME ""
ios_base :: sync_with_stdio (0);
cin.tie (0);
if ( fopen( TASKNAME ".inp", "r" ) ) {
freopen (TASKNAME ".inp", "r", stdin);
freopen (TASKNAME ".out", "w", stdout);
}
int t;
cin >> t;
while (t --)
solve();
return 0;
}