zoukankan      html  css  js  c++  java
  • Hankson的趣味题

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    typedef long long ll;
    
    const ll maxn=20000+10;
    ll ma,mb,mc,md,mx,a,b,c,d,x;
    ll prime[maxn],cnt[maxn];
    ll top;
    bool p[4000000+10];
    
    ll getnum(ll gc,ll t){
        ll num=0;
        while(t%gc==0){
            num++;
            t/=gc;
        }
        return num;
    }
    
    ll check(ll gc){
         ma=getnum(gc,a);
         mb=getnum(gc,b);
         mc=getnum(gc,c);
         md=getnum(gc,d);
         ll num=0;
         if(ma>mc&&mb<md&&mc==md) num++;
         if(ma>mc&&mb==md&&mc<=md) num++;
         if(ma==mc&&mb<md&&mc<=md) num++;
         if(ma==mc&&mb==md&&mc<=md) num+=(md-mc+1);
         return num;
    }
    
    int main(){
        //freopen("vvv.out","w",stdout);
        ll n;
        for (ll i=2;i<=2000000;i++){
            if(p[i]) continue;
            for(ll j=i;j<=2000000/i;j++){
                p[i*j]=true;
            }
        }
        ll m=0;
        for (ll i=2;i<=2000000;i++) if(!p[i]) prime[++m]=i;
        scanf("%lld",&n);
        while(n--){
            top=0;
            ll ans=1;
            memset(cnt,1,sizeof(cnt));
            scanf("%lld%lld%lld%lld",&a,&c,&b,&d);
             if (a%c||d%b) {printf("0
    ");continue;}
            for (ll i=1;prime[i]<=d;i++){
                if(d%prime[i]==0){
                    cnt[++top]=check(prime[i]);//prllf("%d
    ",cnt[top]);
                }
            }
            for (ll i=1;i<=top;i++){
                ans*=cnt[i];
            }
            //if(ans==1) printf("%d
    ",0);
            printf("%lld
    ",ans);
        }
    return 0;
    }
  • 相关阅读:
    HDOJ 1241 Oil Deposits【最大连通块 dfs】
    POJ 3984 迷宫问题【迷宫最短路径 bfs】
    封装
    继承的另一种使用方式。。。
    类的绑定方法与继承
    XML模块与类的定义
    常用模块三
    python day19
    常用模块与项目目录规范
    python day17
  • 原文地址:https://www.cnblogs.com/lmjer/p/9084479.html
Copyright © 2011-2022 走看看