Toot Toot
To give a number x, let you ask for such a longest sequence, and the longest sequence of the number of species:
1. The No. 0 item is 1, and the last item is x (the sequence length does not count the two).
2. Each item is a factor of x.
3. For any AI and Ai+1,ai < ai+1 and AI | Ai+1.
Each item is a factor of x, then the first decomposition of x factorization, the number of these numbers must be X Factor. Then to meet the third, then the ai+1 must be multiplied by the AI by a qualitative factor, so the longest length is the coefficient of mass index and tot.
Re-seeking scheme: first, regardless of pici, CI = 1, then the first number has tot seed selection method, the second number has tot-1 species ... So the total scheme number is tot!. Consider the number of repetitions and divide it by ci!.
1#include <cstdio>2#include <iostream>3#include <cmath>4#include <algorithm>5#include <cstring>6#include <cstdlib>7#include <cctype>8#include <vector>9#include <stack>Ten#include <queue> One using namespacestd; A #defineEnter puts ("") - #defineSpace Putchar (") - #defineMem (A, X) memset (A, X, sizeof (a)) the #defineRG Register -typedefLong Longll; -typedefDoubledb; - Const intINF =0x3f3f3f3f; + ConstDB EPS = 1e-8; - //const int MAXN =; + inline ll read () A { atll ans =0; - Charch = GetChar (), last =' '; - while(!isdigit (CH)) {last = ch; ch =GetChar ();} - while(IsDigit (CH)) {ans = ans *Ten+ CH-'0'; CH =GetChar ();} - if(Last = ='-') ans =-ans; - returnans; in } -InlinevoidWrite (ll x) to { + if(X <0) x =-X, Putchar ('-'); - if(x >=Ten) Write (X/Ten); thePutchar (x%Ten+'0'); * } $ Panax Notoginseng intN; -ll fac[ +]; the voidInit () + { Afac[1] =1; the for(inti =2; I < +; ++i) Fac[i] = fac[i-1] *i; + } - $ voidSolveintN) $ { - inttot =0; -ll und =1; the for(inti =2; I * I <= N; ++i) - {Wuyi if(! (n%i)) the { - intCNT =0; Wu for(; ! (n% i); n/= I, cnt++); -Tot + =CNT; Aboutund *=fac[cnt]; $ } - } - if(N >1) tot++; -Write (tot); Space Write (Fac[tot]/und); Enter; A } + the intMain () - { $ init (); the while(SCANF ("%d", &n)! =EOF) solve (n); the return 0; the}View Code
POJ3421 X-factor Chains