結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-05-31 21:46:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 136 ms / 2,000 ms |
| コード長 | 586 bytes |
| コンパイル時間 | 1,775 ms |
| コンパイル使用メモリ | 193,612 KB |
| 最終ジャッジ日時 | 2025-02-21 17:42:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 16 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--)
{
long A,B;
cin>>A>>B;
int ans=1<<30;
for(int X=0;X<=100000;X++)if((B+X)%(A+X)==0)
{
ans=X;
break;
}
for(int k=2;B-k*A>=0&&k<=100000;k++)
{
if((B-k*A)%(k-1)==0)
{
int X=(B-k*A)/(k-1);
ans=min(ans,X);
}
}
if(ans==1<<30)ans=-1;
cout<<ans<<'\n';
}
}
nonon