結果

問題 No.2767 Add to Divide
ユーザー Ywestbuilderk
提出日時 2024-05-31 23:02:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 191,756 KB
最終ジャッジ日時 2025-02-21 18:27:37
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	int t;
	cin >> t;
	for(int i = 0;i < t;i++){
	int a,b;
	cin >> a >> b;
	int c = b - a;
	if(c < a) cout << -1 << endl;
	else{
		int ans = INT_MAX;
		for(int j = 1;j * j <= c;j++){
			if(c % j == 0){
				if(j >= a) ans = min(ans,j);
				if(c / j >= a) ans = min(ans,c / j);
				
			}
		}
		cout << ans - a << endl;
	}
	}
}
0