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. [转帖]idea配置tomcat参数,防止nvarchar保存韩文、俄文、日文等乱码

    描述下我的场景: 数据库服务器在远程机器上,数据库使用的Oracle,字符集是ZHS16GBK,但保存韩文.俄文.日文等字段A的数据类型是nvarchar(120),而nvarchar使用的是Unic ...

  2. [转帖]命令行非明文密码连接 TiDB

    https://tidb.net/blog/6794a34b#%E6%96%B9%E5%BC%8F%E4%B8%80%EF%BC%9A%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BE ...

  3. [转帖]Jmeter中线程组和setUP线程组、tearDown线程组的区别

    JMETER: setUP线程组:在测试任务ThreadGroup 运行前先被运行.通常用在运行测试任务前,做初始化工作.例如建立数据库连接初始分化工作.用户登录 tearDown线程组:在测试任务线 ...

  4. [转帖]Linux 内核 | 网络流量限速方案大 PK

    https://maimai.cn/article/detail?fid=1674483493&efid=UXVPILU_JTlqLrYhTkDStA 网络流量限速是一个经久不衰的话题,Lin ...

  5. [转帖]UTF8 和 AL32UTF8 的区别

    本文章向大家介绍UTF8 和 AL32UTF8 的区别,主要内容包括 .使用实例.应用技巧.基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下.  UTF8 和 AL32UTF8 ...

  6. Ubuntu2204设置固定IP地址

    前言 Ubuntu每次升级都会修改一部分组件. 从1804开始Ubuntu开始使用netplan的方式进行网络设置. 但是不同版本的配置一直在升级与变化. 今天掉进坑里折腾了好久. 所以这边总结一下, ...

  7. linux如何配置ssh密钥登录

    为什么要用ssh密钥登录 购买的服务器设置密码很容易被暴力破解,用密钥登录安全很多.root用户新建的用户也要用密钥登录更安全,如果一直su - 用户名登录 不方便 用xftp等服务上传文件到用户使用 ...

  8. Gorm 数据库表迁移与表模型定义

    目录 一.Docker快速创建MySQL实例 1.1 创建 1.3 创建数据库 二.AutoMigrate介绍与使用 2.1 AutoMigrate介绍 2.2 AutoMigrate 基本使用 三. ...

  9. FileReader读取文件(文本和图片)

    1.读取文本 let file = input_file.files[0] let fr = new FileReader(); fr.readAsText(file,'gb2312'); //设置文 ...

  10. 解决.netWebAPI输出时间格式带T问题

    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add( new Ne ...