Untitled

 avatar
unknown
c_cpp
a year ago
1.1 kB
4
Indexable
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define PB push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define all(a) a.begin(), a.end()
#define SZ(x) (int)x.size()
#define x first
#define y second
#define PI acos(-1)
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e18;
const int MOD = 1e9 + 7;

void solve(){
    int n, x;
    cin >> n >> x;

    int m = n - x, mm = n + x - 2;
    // cout << m << " " << mm << endl;
    vector<int> v;
    set<int> st;
    for(int i=1; i*i<=m; i++){
        if(m % i == 0){
            int a = i, b = m/i;
            if(a % 2 == 0) v.PB((a+2)/2);
            if(b % 2 == 0) v.PB((b+2)/2);
        }
    }
    for(int i=1; i*i<=mm; i++){
        if(mm % i == 0){
            int a = i, b = mm/i;
            if(a % 2 == 0) v.PB((a+2)/2);
            if(b % 2 == 0) v.PB((b+2)/2);
        }
    }
    for(auto k : v){
        if(k >= x) st.insert(k);
    }
    cout << st.size() << endl;
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int T = 1;
    cin >> T;
    while(T--){
        solve();
    }
}
Leave a Comment