Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Count of factors
//g++ 7.4.0 #include <bits/stdc++.h> using namespace std; const int N = 100001; int factors[N]; void fun(){ factors[1] = 1; for(int i=2;i<N;i++){ factors[i]=i; } for(int i=4;i<N;i+=2){ factors[i]=2; } for(int i=3;i*i<N;i++){ if(factors[i]==i){ for(int j=2*i;j<N;j+=i){ if(factors[j]==j) factors[j]=i; } } } } int solve(int n){ int ans=1; int cnt=1; int d = factors[n]; int next = n/factors[n]; while(next!=1){ if(factors[next]==d){ cnt++; } else{ ans = ans * (cnt+1); cnt = 1; d = factors[next]; } next = next/factors[next]; } ans = ans * (cnt+1); return ans; } int main() { fun(); cout<<solve(20); }
run
|
edit
|
history
|
help
0
insertion_sort
Dar
big boom!
pyramid
Test 1(2021)
Least missing num
Print Euler Path
star print1
Binary Tree
შუალედური მეოთხე საკითხი.Mobile tariff "Cents"