当前位置:网站首页>数学知识:约数个数—约数
数学知识:约数个数—约数
2022-06-21 22:27:00 【奋斗吧!骚年!】
题目:AcWing 870. 约数个数
给定 n 个正整数 ai,请你输出这些数的乘积的约数个数,答案对 109+7 取模。
输入格式
第一行包含整数 n。
接下来 n 行,每行包含一个整数 ai。
输出格式
输出一个整数,表示所给正整数的乘积的约数个数,答案需对 109+7 取模。
数据范围
1≤n≤100,
1≤ai≤2×109
输入样例:
3
2
6
8
输出样例:
12
约数推导
因为一个数可以因式分解
N = p1a1 * p2a2 * …pkak
那么每一个P都是一个质数,选择可以选择 0~a1个 相乘就是一个约数
那么总个数就是(a1+1)*(a2+1) …(ak+1)
#include <iostream>
#include <unordered_map>
using namespace std;
const int mod = 1e9+7;
int main()
{
unordered_map<int,int> primes;
int n;
cin>>n;
while(n--)
{
int x;
cin>>x;
for(int i=2;i<=x/i;i++)
{
while(x%i==0)
{
primes[i]++;
x=x/i;
}
}
if(x>1)primes[x]++;
}
long long res=1;
for(auto it:primes)res=res*(it.second+1)%mod;
cout<<res<<endl;
return 0;
}
边栏推荐
- We sincerely invite elastic stack developers to become CSDN elastic cloud community administrators
- Is Oriental Fortune futures regular? Is this platform safe and reliable?
- Component value transfer: value transfer between siblings (value transfer by non parent and child components)
- 组件传值:父组件与子组件传值用props
- Must the database primary key be self incremented? What scenarios do not suggest self augmentation?
- 布局路线图,空间布局与数据可视化的完美结合
- buuctf misc 间谍启示录
- redis主从复制(九)
- 目标检测、视觉弱监督学习、大脑多模态成像技术等CV综述来了!图像图形学发展年度报告综述专刊!
- 【yarn】Name contains illegal characters
猜你喜欢

Layout roadmap, the perfect combination of spatial layout and data visualization

MNIST image classification and comparison based on K-nearest neighbor

组件传值:子组件向父组件传递数据

组件传值:兄弟间传值(非父子组件进行传值)

Win11热点连接成功但没网?Win11移动热点和网络冲突的解决方法

目标检测、视觉弱监督学习、大脑多模态成像技术等CV综述来了!图像图形学发展年度报告综述专刊!

Win11 how to change the desktop file path to disk D

Academician Zhang Jun: the latest paper on unmanned intelligence group and its social integration, Journal of the Chinese Academy of Engineering

buuctf misc 小易的U盘

Based on vscode platformio under Arduino framework, one project is configured with two compatibility modes of different development boards
随机推荐
洞见数据价值,启迪数字未来,《数字化的力量》问世
211高校神級碩士論文刷屏!75行字錯了20行!學校回應:導師停招...
Operate files through QT drag events
微博关闭发布多个兼职诈骗信息违规账号:如何打击数据造假灰产
Redis master-slave replication (9)
211 thèse de maîtrise en divinité à l'Université! 75 lignes et 20 mauvaises lignes! Réponse de l'école: le tuteur a arrêté d'inscrire...
Here comes the CV overview of target detection, visual weakly supervised learning, brain multimodal imaging technology and so on! Image graphics development annual report review special issue!
【golang】Cannot convert expression of type ‘interface{}‘ to type ‘string‘(解决方案)
Software testing -- Classification of tests
数据库主键一定要自增吗?有哪些场景不建议自增?
katalon Recoder常用命令
[RoarCTF2019]黄金6年
Reprint: network loading framework - retrofit
所谓的0拷贝不就是为了让CPU休息吗?深入理解mmap
The third "invalidation" of the prospectus of Yiteng pharmaceutical in Hong Kong: the listing was substantially delayed, Sequoia and other shareholders
CPDA | what basic skills do data analysts need?
Student management system experiment report -asp Net programming
基于Arduino框架下VSCode PlatformIO一个项目配置两种不同开发板的兼容模式
211 college Master of divinity thesis swipe the screen! 75 lines wrong 20 lines! School response: the tutor stopped recruiting
IDA静态逆向分析工具使用详解