結果
問題 |
No.2767 Add to Divide
|
ユーザー |
|
提出日時 | 2024-09-04 22:18:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 1,900 ms |
コンパイル使用メモリ | 192,544 KB |
最終ジャッジ日時 | 2025-02-24 03:52:57 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; B-=A; if(B==0){ cout<<0<<endl; continue; } int an=1e9+10; for(int i=1;i*i<=B;i++){ if(B%i==0){ int e=i; if(e>=A)an=min(an,e-A); e=B/i; if(e>=A)an=min(an,e-A); } } cout<<(an<1e9+5?an:-1)<<endl; } }