結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 22:25:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 414 bytes |
| コンパイル時間 | 1,982 ms |
| コンパイル使用メモリ | 193,316 KB |
| 最終ジャッジ日時 | 2025-02-21 18:05:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main () {
int T;
cin >> T;
while (T--) {
int a, b;
cin >> a >> b;
if (b % a == 0) {
puts("0");
} else {
int d = b - a;
int p = d;
for (int x = 2; x * x <= d; x ++) {
if (d % x == 0) {
if (a <= x) {
p = x;
break;
}
if (a <= d / x) {
p = d / x;
}
}
}
cout << max(-1, p - a) << endl;
}
}
}