結果

問題 No.1200 お菓子配り-3
ユーザー kyoprounokyoprouno
提出日時 2020-08-28 22:10:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,719 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 177,180 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 08:44:49
合計ジャッジ時間 17,540 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 12 ms
4,380 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 102 ms
4,380 KB
testcase_13 AC 104 ms
4,380 KB
testcase_14 AC 104 ms
4,380 KB
testcase_15 AC 106 ms
4,380 KB
testcase_16 AC 104 ms
4,376 KB
testcase_17 AC 373 ms
4,376 KB
testcase_18 AC 537 ms
4,380 KB
testcase_19 AC 121 ms
4,384 KB
testcase_20 AC 1,046 ms
4,380 KB
testcase_21 AC 1,033 ms
4,376 KB
testcase_22 AC 1,208 ms
4,380 KB
testcase_23 AC 1,025 ms
4,380 KB
testcase_24 AC 1,012 ms
4,376 KB
testcase_25 AC 1,017 ms
4,380 KB
testcase_26 AC 1,011 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 804 ms
4,376 KB
testcase_29 AC 2,235 ms
4,384 KB
testcase_30 AC 2,251 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0