結果
問題 | No.2767 Add to Divide |
ユーザー |
|
提出日時 | 2024-05-31 21:33:30 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 2,489 ms |
コンパイル使用メモリ | 207,664 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 22:36:30 |
合計ジャッジ時間 | 3,815 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
#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;if(a == b){cout << 0 << endl; continue;}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 << endl;}}