zoukankan      html  css  js  c++  java
  • LCM Cardinality UVA

    这题就是

    LightOJ - 1236

    解析去看这个把https://www.cnblogs.com/WTSRUVF/p/9185140.html

    贴代码了;

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define maxn 10000900
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int LL_INF = 0x7fffffffffffffff,INF = 0x3f3f3f3f;
    LL primes[maxn/10];
    bool vis[maxn];
    LL 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()
    {
        init();
        LL n;
        while(cin>> n && n)
        {
            LL res = 1, cnt = 0;
            LL temp = n;
            for(LL i=0; i<ans && primes[i] * primes[i] <= n; i++)
            {
                LL cnt2 = 0;
                while(n % primes[i] == 0)
                {
                    n /= primes[i];
                    cnt2++;
                }
                if(cnt2 > 0)
                {
                    res *= (2*cnt2 + 1);
                }
            }
            if(n > 1)
            {
                res *= 3;
            }
            printf("%lld %lld
    ",temp,res/2+1);
        }
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    最近重感冒完全不知道知己在记什么

    倾尽一生
    学习笔记,函数
    唯美句
    02 mysql 基础二 (进阶)
    01 mysql 基础一 (进阶)
    16 正则表达式
    15 迭代器、生成器、模块和包
    14 异常
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9318206.html
Copyright © 2011-2022 走看看