結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-02-29 21:58:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 639 bytes |
| コンパイル時間 | 1,961 ms |
| コンパイル使用メモリ | 195,852 KB |
| 最終ジャッジ日時 | 2025-02-19 22:05:05 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int> factor;
void all_factor(int n){
factor.clear();
for (int i = 1; i*i <= n; i++){
if (n % i == 0){
factor.push_back(i);
if (i*i != n) factor.push_back(n / i);
}
}
}
void solve(){
int A, B, mi=2e9;
cin >> A >> B;
all_factor(B-A);
for (auto x : factor){
if (x >= A) mi = min(mi, x);
}
if (mi == 2e9) cout << -1 << '\n';
else cout << mi-A << '\n';
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int T;
cin >> T;
while(T--) solve();
return 0;
}
srjywrdnprkt