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. vCenter6.7 无法启动

    Get service 567f6edd-d4f7-4bfb-905b-1834c758a99d_com.vmware.vsphere.clientDon't update service 567f6 ...

  2. [转帖]crash工具分析Kdump下vmcore文件常用命令总结(三)(实例易懂)

    一.简介 本文主要介绍使用crash工具对kdump生成的vmcore文件进行分析,解析常见的crash命令,前面已讲述两章关于Kdump的内容,读者感兴趣可以点击下面的链接: 1.Kdump调试机理 ...

  3. [转帖]一次操作系统报错OutOfMemory Error的处理记录

    在启动公司内嵌的tomcat容器时出现报错, 如下: # There is insufficient memory for the Java Runtime Environment to contin ...

  4. 二进制安装Mysql数据库的快速方法

    二进制安装Mysql数据库的快速方法 摘要 还是国产操作系统 rpm包可能不太兼容,为了简单准备使用tar包方式安装mysql数据库 这里简单记录一下过程. 为以后使用. 介质下载 下载二进制的tar ...

  5. How to Use Github

    C:\Windows\System32\drivers\etc\hosts 在最后加上一句 20.205.243.166 github.com 从 https://ping.chinaz.com/ 来 ...

  6. k8s笔记——NodePort暴露nginx-controller实现https自动跳转自定义nodePort端口

    安装nginx-controller并暴露nodePort helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx ...

  7. py 学习(c++ to py)

    py1: print 2024-01-27 23:18:57 星期六 #这里是注释 # py1 : 基础print总结 ''' aaa 有时候也用三个单引号当注释 但其实是字符串 交互式会输出 ''' ...

  8. 为mac搭建开发环境的笔记

    公司的游戏项目需要出ios包上架到app store,由我负责接入ios的sdk,这里记录一下为mac搭建开发环境的笔记,大多是软件和编程习惯相关的内容. 常用软件 解压缩软件:bandizip在ma ...

  9. TienChin 渠道管理-渠道类型

    在上一篇文章当中,表里面有一个渠道类型,我们这节主要是将这个渠道类型创建好,首先我们来看看字典表. sys_dict_type 表: 字段名 数据类型 注释 dict_id bigint 字典主键 d ...

  10. 设计模式学习-使用go实现中介者模式

    中介模式 定义 优点 缺点 适用范围 代码实现 参考 中介模式 定义 中介模式(Mediator):用一个中介对象来封装一系列的对象交互.中介者使个各对象不需要显示的相互引用,从而使其藕合松散,而且可 ...