当前位置:网站首页>Acwing 870. approximate number
Acwing 870. approximate number
2022-07-25 03:23:00 【_ Liu Xiaoyu】
Given n A positive integer ai, Please output the divisor of the product of these numbers , The answer is right 109+7 modulus .
Input format
The first line contains integers n.
Next n That's ok , Each line contains an integer ai.
Output format
Output an integer , Represents the number of divisors of the product of a given positive integer , The answer needs to be right 109+7 modulus .
Data range
1≤n≤100,
1≤ai≤2×109
sample input :
3
2
6
8
sample output :
12

Example :
24=2 * 2 * 2 * 3 = 23* 3, Then add one to the exponent of each prime number and multiply it, that is, the divisor of this number , That is to say (3 + 1)(1 + 1) = 4 * 2 = 24
24 The divisor of is : 1,2,3,4,6,8,12,24
Ideas :
First decompose the original number into prime factors , Finally, add up the exponents of each number . from a1 Until an, because a The data is too large , Here we use hash table to store .
Hashtable first Storage base , second Storage index .
code:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long LL;
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)
{
x /= i;
primes[i] ++;
}
if(x > 1) primes[x] ++; // Greater than n / i The quality factor of
}
LL re = 1;
for(auto t : primes) re = re * (t.second + 1) % mod; // The formula
cout << re << endl;
return 0;
}
边栏推荐
- [stm32f103rct6] can communication
- Day 10: BGP border gateway protocol
- New features commonly used in ES6
- MySQL configuration in CDH installation
- Test question C: question brushing statistics
- Implementation principle of virtual DOM
- NVM installation and use
- Sword finger offer II 041. Average value of sliding window_____ Using queue / loop array implementation
- C language function operation
- Take a database statement note: when the field is empty, assign the default value to the result
猜你喜欢

Why does the legend of superstar (Jay Chou) not constitute pyramid selling? What is the difference between distribution and pyramid selling?

Unified return data format

Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development

Decoding webp static pictures using libwebp

mysql_ Case insensitive

Openlayers draw circles and ellipses

VMware installation

Record once C # extract audio files with ffmempeg

Riotboard development board series notes (VII) -- the use of framebuffer

Secondary vocational network security skills competition P100 dcore (light CMS system) SQL injection
随机推荐
Color space (1) - RGB
Analysis of cascading relation operation examples of cascade
Zhanrui Mobile Phone Unlocked
ECMAScript new features
How to use two queues to simulate the implementation of a stack
New features commonly used in ES6
[template engine] microservice Learning Notes 6: freemaker
Analysis of DNS domain name resolution process
FLASH read / write problem of stm32cubemx
Force the resumption of game 302 of the week
Learning Record V
Query the information of students whose grades are above 80
Task02 | EDA initial experience
Swiper4 is used to smooth longitudinal seamless scrolling. After clicking or dragging the mouse, the animation is not completely completed, the mouse moves out of the automatic rotation, and the dynam
Take a database statement note: when the field is empty, assign the default value to the result
Canvas record
Publish the project online and don't want to open a port
Dynamic planning of force buckle punch in summary
Function of each layer of data warehouse
Use reflection to convert RDD to dataframe