AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 问答
    • 吐槽
  • App
  • 登录/注册

AcWing 870. 约数个数    原题链接    简单

作者: 作者的头像   金樽馔玉 ,  2022-12-22 17:29:21 ,  所有人可见 ,  阅读 71


0


题目描述

blablabla

样例

blablabla

算法1

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

blablabla

算法2

(暴力枚举) $O(n^2)$

blablabla

时间复杂度

参考文献

C++ 代码

#include<iostream>
#include<unordered_map>


using namespace std;

typedef long long LL;

const int N = 110, mod = 1e9 + 7;


int main()
{
    int n;
    cin >> n;

    unordered_map<int, int> primes;

    while (n--){
        int x;
        cin >> x;

        // 把因子 i 的个数统计清楚
        for (int i = 2; i <= x / i; i++)
        {
            while (x % i == 0)
            {
                x /= i;
                primes[i]++;
            }


        }

        if (x > 1) primes[x]++;
    }

    LL res = 1;

    for (auto it : primes) res = res * (it.second + 1) % mod;
    cout << res << endl;
    return 0;
}

0 评论

你确定删除吗?

© 2018-2023 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标 qq图标
请输入绑定的邮箱地址
请输入注册信息