当前位置:网站首页>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;
}
边栏推荐
- How chemical enterprises choose digital service providers with dual prevention mechanism
- Hashcode details
- Force deduction brush question 26. Delete duplicates in the ordered array
- PHP record
- Experiment 4 CTF practice
- Database transactions (often asked)
- Query the information of students whose grades are above 80
- Modulenotfounderror: no module named 'pyemd' solution
- Secondary vocational network security skills competition P100 web penetration test
- How does Jupiter notebook change themes and font sizes?
猜你喜欢

05 - MVVM model

mysql_ Case insensitive

Swagger key configuration items

VMware installation

Riotboard development board series notes (4) -- using Vpu hardware decoding

What should testers do if they encounter a bug that is difficult to reproduce?

Banana pie bpi-m5 toss record (2) -- compile u-boot

Merge sort / quick sort

Dc-2-range practice

Banana pie bpi-m5 toss record (3) -- compile BSP
随机推荐
Use and introduction of vim file editor
The relationship between private domain traffic and fission marketing. What is super app? Can our enterprise own it?
Li Kou 343 integer partition dynamic programming
Sword finger offer II 041. Average value of sliding window_____ Using queue / loop array implementation
A queue of two stacks
Can bus baud rate setting of stm32cubemx
New features commonly used in ES6
List type to string type
Introduction to Apache Doris grafana monitoring indicators
Ffmpeg 4.3 add custom demuxer
LeetCode. 302 weekly games___ 03_ 6121. Query the number smaller than k after cutting the number____ sort
Table of contents of force deduction questions
C language introduction practice (9): completion judgment
B. All Distinct
Easyexcel sets the style of the last row [which can be expanded to each row]
Li Kou 279 complete square - dynamic programming
mysql_ User table_ Field meaning
Dc-1-practice
How to use two queues to simulate the implementation of a stack
Algorithmic interview questions