結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 22:24:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 415 bytes |
| コンパイル時間 | 1,959 ms |
| コンパイル使用メモリ | 192,540 KB |
| 最終ジャッジ日時 | 2025-02-21 18:04:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 15 |
ソースコード
#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 = -1;
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;
}
}
}