Divisors of the Divisors of an Integer

题意:定义d[x]为x的因子个数,sndd[y]为y的因子的因子个数和。

思路:任意一个大于一的数,都可以分解为若干个质数的乘积。所以,这个问题可以转换成一个有关质数的问题。

如果x是一个质数,那么d[x^u] = u + 1。

分类加法,分步乘法。首先,每一步先选出来一个质数进行操作,对于每一个质数,需要将多种可能情况进行加和。

#include<bits/stdc++.h>
#define int long long
using namespace std; const int N = 1e6 + 10;
const int mod = 1e7 + 7;
int n, t, prime[N], tot;
bool mark[N];
typedef pair<int,int> pii;
vector<pii> vet; void get_prime(){
for(int i = 2; i <= 1e6; i++){
if(!mark[i]){
prime[++tot] = i;
mark[i] = 1;
}
for(int j = 1; j <= tot; j ++){
if(i * prime[j] > 1e6) break;
mark[i * prime[j]] = 1;
if(i % prime[j] == 0) break;
}
}
} //每个因数对答案的贡献是可以的算出来的 signed main(){
get_prime();
while(cin >> n){
//cin >> n;
if(n == 0) break;
vet.clear();
for(int i = 1; i <= tot; i ++){
//int x = n / prime[i];
int y = n, x = 0;
while(y){
x += y/prime[i];
y = y / prime[i];
}
if(x >= 1){
vet.push_back({prime[i], x});
}
}
int ans = 1;
for(int i = 0; i < vet.size(); i++){
int u = 0;
int x = vet[i].first, y = vet[i].second;
ans = ans * ((y + 1) + ((y + 1) * y / 2)%mod)% mod;
}
cout << ans << endl;
}
return 0;
}

Divisors of the Divisors of an Integer题解的更多相关文章

  1. 2018-2019 ACM-ICPC, Asia Dhaka Regional Contest C.Divisors of the Divisors of An Integer (数论)

    题意:求\(n!\)的每个因子的因子数. 题解:我们可以对\(n!\)进行质因数分解,这里可以直接用推论快速求出:https://5ab-juruo.blog.luogu.org/solution-p ...

  2. AtCoder Beginner Contest 115 题解

    题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...

  3. LeetCode Perfect Number

    原题链接在这里:https://leetcode.com/problems/perfect-number/#/description 题目: We define the Perfect Number ...

  4. 【LeetCode】数学(共106题)

    [2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/979 ...

  5. 【leetcode 29】 两数相除(中等)

    题目描述 给定两个整数,被除数 dividend 和除数 divisor.将两数相除,要求不使用乘法.除法和 mod 运算符. 返回被除数 dividend 除以除数 divisor 得到的商. 整数 ...

  6. C Primer Plus(第五版)7

    第 7 章 C 控制语句:分支和跳转 在本章中你将学习下列内容: · 关键字:if(如果),else(否则),switch(切换),continue(继续),break(中断), case(情况),d ...

  7. [leetcode-507-Perfect Number]

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  8. 507. Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  9. [LeetCode] Perfect Number 完美数字

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  10. [Swift]LeetCode507. 完美数 | Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

随机推荐

  1. [转帖]Archery

    Archery SQL 审核查询平台          文档 | FAQ | Releases 功能清单 数据库 查询 审核 执行 备份 数据字典 慢日志 会话管理 账号管理 参数管理 数据归档 My ...

  2. [转帖]存储器分级:L1 Cache 比内存和 SSD 快多少倍?

    目录 1.为什么会有存储器分级策略? 2.存储器分级策略 2.1 存储器的级别 2.2.1 L1-Cache 2.2.2 L2-Cache 2.2.3 L3-Cache 3.内存 4.SSD 和硬盘 ...

  3. [转帖]Prometheus系列之Grafana 版本9.0.0 设置Email邮件报警实战

    目录 1. 配置文件conf/defaults.ini修改 2. Grafana Web页面配置报警邮箱接收者 3. 创建Dashboard 4. 创建Alert的文件夹 5. 设置Notificat ...

  4. [转帖]Chrome 109发布,最后一个支持Windows 7/8的版本

    https://www.163.com/dy/article/HQR3QQFD0511CUMI.html 出品 | OSC开源社区(ID:oschina2013) Google 在去年 12 月 1 ...

  5. [转帖]Shell~echo -e 颜色输出

    https://www.cnblogs.com/ElegantSmile/p/11144879.html echo -e 可以控制字体颜色和背景颜色输出 从一个例子开始: # echo -e &quo ...

  6. [转帖]耗时几个月,终于找到了JVM停顿十几秒的原因

    https://www.cnblogs.com/codelogs/p/16060792.html   原创:打码日记(微信公众号ID:codelogs),欢迎分享,转载请保留出处. 简介# 最近我们系 ...

  7. Linux 一行命令 仅显示某一个网卡的ip地址

    最简答的方法 1. 先使用 ifconfig 查看网卡的设备名 2. 然后输入命令 ifconfig ens192 |grep 'inet ' |cut -d " " -f 10命 ...

  8. 如何在proto3中用上golang对应的interface{}类型

    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 首先,我希望所有golang中用于http请求响应的结构, ...

  9. 从Spring源码看Spring如何解决循环引用的问题

    Spring如何解决循环引用的问题 关于循环引用,首先说一个结论: Spring能够解决的情况为:两个对象都是单实例.且通过set方法进行注入. 两个对象都是单实例,通过构造方法进行注入,Spring ...

  10. 发布.net core应用程序并部署到IIS上

    一.在项目里右击选择发布点击启动配置如下图所示 二.在打开的发布选项选择 配置 Release或DeBug ,目标框架选择对应的.net Core版本默认就行,部署模式有两种选择 1.框架依赖---- ...