結果
問題 | No.1200 お菓子配り-3 |
ユーザー |
![]() |
提出日時 | 2020-08-28 22:10:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,719 bytes |
コンパイル時間 | 2,226 ms |
コンパイル使用メモリ | 179,128 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 15:21:08 |
合計ジャッジ時間 | 18,870 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 2 |
ソースコード
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair<ll,ll> #define pii pair<int,int> #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; inline int topbit(unsigned long long x){ return x?63-__builtin_clzll(x):-1; } inline int popcount(unsigned long long x){ return __builtin_popcountll(x); } inline int parity(unsigned long long x){//popcount%2 return __builtin_parity(x); } template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} const ll INF=1e15; int main(){ ios; ll s; cin >> s; while(s--){ ll x,y; cin >> x >> y; if(x<y) swap(x,y); ll z=x-y; ll ans=0; if(z==0){ cout << x-1 << endl; continue; } vector<ll> p; for(ll i=1;i*i<=z;i++){ if(z%i==0){ if(i*i==z){ p.push_back(i); } else{ p.push_back(i); p.push_back(z/i); } } } for(auto q:p){ ll a=q+1; if(a*x>y && a*y>x){ if((a*x-y)%(a*a-1)==0 && (a*y-x)%(a*a-1)==0){ ans++; } } } cout << ans << endl; } return 0; }