結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 21:58:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 674 bytes |
| コンパイル時間 | 6,603 ms |
| コンパイル使用メモリ | 335,760 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-12-20 23:21:36 |
| 合計ジャッジ時間 | 17,024 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 TLE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//using mint = modint998244353;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
ll f(ll a,ll b){
ll c=1;
vector<ll>ans;
if(b%a==0)return 0;
while(b-a*c>=c-1&&b-a*c>0){
c++;
ll d=(b-a*c)%(c-1);
ll e=(b-a*c)/(c-1);
if(d==0&&e>0)ans.push_back (e);
}
if(!ans.empty())return ans[ans.size()-1];
return -1;
}
int main() {
int t;
cin>>t;
while(t--){
ll a,b;
cin>>a>>b;
cout<<f(a,b)<<endl;
}
return 0;
}