1 条题解

  • 0
    @ 2026-9-30 13:01:01

    C++ :

    #include <cstdio>
    #include <set>
    typedef long long ll;
    static ll g(ll a,ll b){ return b ? g(b, a%b) : a; }
    int main(){
        ll a,b,c;
        if(scanf("%lld %lld %lld",&a,&b,&c)!=3) return 0;
        std::set<ll> divs;                       /* 至少是 2 个数的约数 <=> 整除某个 pair 的 gcd */
        ll gs[3] = { g(a,b), g(a,c), g(b,c) };
        for(int t=0;t<3;t++){
            ll x = gs[t];
            if(x<=0) continue;
            for(ll i=1;i*i<=x;i++)
                if(x%i==0){ divs.insert(i); divs.insert(x/i); }
        }
        printf("%d\n", (int)divs.size());
        return 0;
    }
    
    
    • 1

    信息

    ID
    2898
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者