結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 21:32:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| コンパイル時間 | 2,282 ms |
| コンパイル使用メモリ | 198,952 KB |
| 最終ジャッジ日時 | 2025-02-21 17:32:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--){
long long a,b; cin >> a >> b;
long long diff = b-a;
vector<long long> D;
for(int i=1; i*i<=diff; i++){
if(diff%i) continue;
D.push_back(i);
D.push_back(diff/i);
}
sort(D.begin(),D.end());
int answer = -1;
for(auto d : D) if(d >= a){answer = d-a; break;}
cout << answer << "\n";
}
}