結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-08-28 21:47:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,395 bytes |
| コンパイル時間 | 2,411 ms |
| コンパイル使用メモリ | 203,000 KB |
| 最終ジャッジ日時 | 2025-01-13 17:01:14 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const char newl = '\n';
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
vector<T> ts(n);
for(size_t i=0;i<n;i++) cin>>ts[i];
return ts;
}
//INSERT ABOVE HERE
using P = pair<Int, Int>;
map<P, Int> memo;
signed solve(){
Int x,y;
cin>>x>>y;
if(x>y) swap(x,y);
if(memo.count(P(x,y))){
cout<<memo[P(x,y)]<<newl;
return 0;
}
Int &res=memo[P(x,y)];
res=0;
if(x==y){
vector<Int> cand;
for(Int i=1;i*i<=x;i++){
if(x%i) continue;
cand.emplace_back(i);
if(i*i!=x) cand.emplace_back(x/i);
}
for(Int c:cand){
Int a=x/c-1;
if(0<a) res++;
}
cout<<res<<newl;
return 0;
}
Int d=y-x;
vector<Int> cand;
for(Int i=1;i*i<=d;i++){
if(d%i) continue;
cand.emplace_back(i);
if(i*i!=d) cand.emplace_back(d/i);
}
for(Int t:cand){
Int a=t+1;
Int s=d/t;
Int b=(x-s)/(a+1);
Int c=s+b;
if(0<a and 0<b and 0<c and a*b+c==x and a*c+b==y) res++;
}
cout<<res<<newl;
return 0;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
Int T;
cin>>T;
while(T--) solve();
return 0;
}
beet