結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
![]() |
提出日時 | 2020-08-29 18:21:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,696 ms / 4,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 2,250 ms |
コンパイル使用メモリ | 192,080 KB |
最終ジャッジ日時 | 2025-01-13 20:31:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) using namespace std; typedef long long ll; const int MOD = 998244353; const ll INF = 4611686018427387903LL; int main() { int S; cin >> S; while (S--) { ll x,y; cin >> x >> y; ll ans=0; for(int k=2;k<=sqrt(x+y);k++){ if((x+y)%k==0){ ll a=k-1; if(a==1){ if(a*y==x){ans+=(x+y)/(a+1)-1;} } else if(a>1&&(a*y-x)>0&&(a*y-x)%(a*a-1)==0){ if(y-a*((a*y-x)/(a*a-1))>0){ ans++; } } a=(x+y)/k-1; if(a<=1)continue; if((a*y-x)>0&&(a*y-x)%(a*a-1)==0){ if(y-a*((a*y-x)/(a*a-1))>0){ ans++; } } } } cout << ans << '\n'; } return 0; }