結果
| 問題 | 
                            No.2767 Add to Divide
                             | 
                    
| コンテスト | |
| ユーザー | 
                             テナガザル
                         | 
                    
| 提出日時 | 2024-06-13 20:33:26 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 456 bytes | 
| コンパイル時間 | 1,437 ms | 
| コンパイル使用メモリ | 102,088 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-13 20:33:30 | 
| 合計ジャッジ時間 | 2,529 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 12 WA * 4 | 
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int a, b;
		cin >> a >> b;
		int tmp = b - a;
		int ans = 2e9;
		for (int i = 1; i * i <= tmp; ++i)
		{
			if (tmp % i == 0)
			{
				if (i >= a)
				{
					ans = min(ans, i - a);
				}
				if (tmp / i >= a)
				{
					ans = min(ans, tmp / i - a);
				}
			}
		}
		cout << (ans >= 2e9 ? -1 : ans) << endl;
	}
}
            
            
            
        
            
テナガザル