Topic Link: Click to open the link
Test instructions: An integer, written in the form of a factor, asking how many ways to write. For example, there are 8 ways to n=12 when you are
12=12;
12=6*2;
12=4*3;
12=3*4;
12=3*2*2;
12=2*6;
12=2*3*2;
12=2*2*3.
All the factors of n are first written in ascending order. For example, 12 of all factors are 2, 3, 4, 6, 12
For 2 There is a 2*1 one; for 3, there is 3*1 one; for 4, there are 4*1 (4/2) two; for 6, there are 6*1, (6/2), (6/3), 3, 12, 12*1, 2*6, 3*4, 4*3 , 2*2*3, 6*2, 2*3*2, 3*2*2, 8 kinds, OK is it, can find the law, for the first factor, set F[i] represents the number of categories of the first factor, initialize F[0]=1, F[i]=1+f[j] (j>=0&&j& Lt;i && fac[i]%fac[j]==0)
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 1005#define _ll __int64#define ll Long long#define INF 0x3f3f3f3f#define Mod 1<<40+10#define pp pair<int,int> #define ull unsigned long longusin G namespace Std;ll n;int tot,fac[100010],f[100010];void Div (ll N) {tot=0;for (ll i=2;i*i<=n;i++) {if (n%i==0) {fac[tot+ +]=i;if (n/i!=i) fac[tot++]=n/i;}} Fac[tot++]=n;} void Solve () {div (n); sort (fac,fac+tot); for (int i=0;i<tot;i++) {f[i]=1;for (int j=i-1;j>=0;j--) if (Fac[i]%fac[j] ==0) f[i]+=f[j];} printf ("%d\n", F[tot-1]);} int main () {while (~scanf ("%lld", &n)) solve (); return 0;}
Sdut 1722-integer factor decomposition problem (factor decomposition)