zoukankan      html  css  js  c++  java
  • LightOJ

    题意:

    就是。。。。求a的所有大于b的因子有多少对

    算术基本定理求 所有因子 阿欧。。。偷张图。

    注意范围 就好  。。。。。

    解析:

    在1 -1012的范围内求大于b的所有a的因子的对数(有几对)

    就等于 在1 -1012的范围内求出a的所有因子 除二  减去  在1 - (b-1)的范围内a的所有因子

    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cstdio>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<map>
    #include<stack>
    #define mem(a,b) memset(a,b,sizeof(a))
    using namespace std;
    typedef long long LL;
    const int maxn=1000010;
    
    LL primes[maxn], vis[maxn];
    LL base[maxn], mi[maxn];
    int ans = 0;
    void init()
    {
        mem(vis,0);
        for(int i=2; i<maxn; i++)
            if(!vis[i])
            {
                primes[ans++] = i;
                for(LL j=(LL)i*i; j<maxn; j+=i)
                    vis[j] = 1;
            }
    }
    
    int main()
    {
        int T;
        init();
        int m = 0;
        scanf("%d",&T);
        while(T--)
        {
            LL S, edge;
            scanf("%lld%lld",&S,&edge);
            LL x = S;
            if(edge * edge >= S){
                printf("Case %d: 0
    ",++m); continue;
            }
            LL res = 1, cnt2 = 0;
            for(int i=0; i < ans && primes[i] * primes[i] <= S; i++)
            {
                LL cnt = 0;
                while(S % primes[i] == 0)
                {
                    cnt++;
                    S /= primes[i];
    
                }
                if(S > 0){
                    base[cnt2] = primes[i];
                    mi[cnt2++] = cnt;
                }
            }
            if(S > 1)
            {
                base[cnt2] = S;
                mi[cnt2++] = 1;
            }
            LL temp = 1;
            for(int i=0; i<cnt2; i++)
            {
                res *= (mi[i]+1);
                if(base[i] < edge)
                    temp *= mi[i];
    
            }
            printf("Case %d: %lld
    ",++m,res/2 - temp);
    
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    构建之法阅读笔记03
    周进度条
    周活动总结表
    电脑桌面美化
    如何让自己进步,去做成一件事
    后台网站
    laravel RBAC权限管理学习
    laravle定时任务
    django第一次简单讲解使用
    css3网页的淡入淡出效果
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9178289.html
Copyright © 2011-2022 走看看