Divisors of the Divisors of an Integer题解
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题解的更多相关文章
- 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 ...
- AtCoder Beginner Contest 115 题解
题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...
- LeetCode Perfect Number
原题链接在这里:https://leetcode.com/problems/perfect-number/#/description 题目: We define the Perfect Number ...
- 【LeetCode】数学(共106题)
[2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/979 ...
- 【leetcode 29】 两数相除(中等)
题目描述 给定两个整数,被除数 dividend 和除数 divisor.将两数相除,要求不使用乘法.除法和 mod 运算符. 返回被除数 dividend 除以除数 divisor 得到的商. 整数 ...
- C Primer Plus(第五版)7
第 7 章 C 控制语句:分支和跳转 在本章中你将学习下列内容: · 关键字:if(如果),else(否则),switch(切换),continue(继续),break(中断), case(情况),d ...
- [leetcode-507-Perfect Number]
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- 507. Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [LeetCode] Perfect Number 完美数字
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [Swift]LeetCode507. 完美数 | Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
随机推荐
- [转帖]060-轻量级基于curl的seafile上传脚本
https://anjia0532.github.io/2021/04/07/seafile-client-curl/ 这是坚持技术写作计划(含翻译)的第 60 篇,定个小目标 999,每周最少 2 ...
- [转帖]Shell if 条件判断
Shell 语言中的if条件 一.if的基本语法: if [ command ];then 符合该条件执行的语句 elif [ command ];then 符合该条件执行的语句 e ...
- [转帖]tidb RESTORE
https://docs.pingcap.com/zh/tidb/v4.0/sql-statement-restore RESTORE 语句用于执行分布式恢复,把 BACKUP 语句生成的备份文件恢复 ...
- [转帖]Jmeter学习笔记(十九)——后置处理器之正则表达式的使用
https://www.cnblogs.com/pachongshangdexuebi/p/11733005.html 一.正则表达式提取器的作用 允许用户从服务器的响应中通过使用perl的正则表达式 ...
- [转帖]Linux常用的一些命令,看你知道多少?
https://zhuanlan.zhihu.com/p/115279009 Linux中命令有很多,而Linux系统中使用命令也是它的一大特点.在Linux系统中使用命令处理问题灵活,高效,所以熟知 ...
- 【转帖】nginx变量使用方法详解-3
https://www.diewufeiyang.com/post/577.html 也有一些内建变量是支持改写的,其中一个例子是 $args. 这个变量在读取时返回当前请求的 URL 参数串(即请求 ...
- [官方]Beyond Compare里面 二进制比较的含义.
Content Comparisons Actions > Compare Contents In the Actions menu, the Compare Contents command ...
- _0x4c9738 怎么还原?嘿,还真可以还原!
_0x4c9738 变量名还原,噂嘟假嘟? 代码混淆(obfuscation)和代码反混淆(deobfuscation)在爬虫.逆向当中可以说是非常常见的情况了,初学者经常问一个问题,类似 _0x4c ...
- 在vscode中运行bat文件(执行bat)并解决中文乱码问题
使用vscode编写bat脚本让工作流得到了极大的改善 以前:在文本编辑器中写完,保存,回到资源管理器双击bat运行,再循环重复 现在:在vscode中编写bat,按下快捷键执行bat 在vscode ...
- 使用 arxiv-sanity &paperwithcode 跟进最新研究领域的文章
1.arxiv-sanity介绍 arxiv.org是一个非常大的预印本资源库,里面有大量的最新的论文,但缺点是浏览.搜索和排序不是很方便.这个资源库每天会更新大量的论文,如果通过手动搜索和浏览则效率 ...