結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
|
提出日時 | 2020-09-26 08:46:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,098 ms / 4,000 ms |
コード長 | 819 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 95,068 KB |
最終ジャッジ日時 | 2025-01-14 22:00:44 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <math.h> #include <map> using namespace std; typedef long long int ll; ll X,Y; ll count_res(ll i,ll j){ if(j<2)return 0; ll A=i-1; if(A==1){ if(X!=Y)return 0; else return X-1; } if((A*Y-X)%(A*A-1))return 0; ll C=(A*Y-X)/(A*A-1); if(C<1)return 0; if((X-C)%A)return 0; ll B=(X-C)/A; return B>=1; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while(q--){ cin >> X >> Y; int x=X+Y; ll res=0; for(int i=2;i*i<=x;i++){ if(x%i==0){ res+=count_res(i,x/i); if(x/i!=i&&x/i>=2)res+=count_res(x/i,i); } } cout << res << "\n"; } }