Universal fourth title group C (8.18)

[1574.] X- factor improving chain 
(File the IO): INPUT: factor.in  Output: factor.out

Time limit:  1000 MS space constraints:  131072 KB

Title Description

Give a positive integer X, a length m X- factor refers to a strand sequence: X0 = 1, X1, X2 ,. . . , Xm = X satisfies: Xi <Xi + 1 at the same time Xi | Xi +. 1 (Xi + Xi be divisible. 1)

 

Factor X- required maximum length of chain length Len and the number of chains of Len X- factor.

 

Entry

     A positive integer X (X <231)

Export

     Line, two integers, respectively, and a maximum length of several of the length of the chain.

 

Sample input

100

Sample Output

4 6

 

Data range limit

Thinking:

A look at the subject, ignorant forced face; look range, two face ignorant force; Revisited subject, ignorant 3 faces force;

(Roh = Д =) Bruno ┻━┻

( Ignorant ignorant to force to force the tree fruit, tree ignorant to force you and me ) into the topic:

This question of violence enumeration Well, just know that the number of non-repetition factor is equivalent to chain-wide arrangement on the line ( feel good to write water ah )

CODE:

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,tot=0;
long long ans=0;
int a[31];
void chazhao(int x)
{
    for(int i=2;i<=x;i++)
    {
        if((x%i)==0)
        {
            a[tot]=i;
            tot++;
            return chazhao(x/i);
        }
    }
}
int main()
{
    freopen("factor.in","r",stdin);
    freopen("factor.out","w",stdout);
    cin>>n;
    chazhao(n);
    do
    {
        ans++;
    }
    while (next_permutation(a,a+tot));
    cout<<tot<<" "<<ans;
    return 0;
}

next_permutation(a,a+tot)

This is something I'm just lazy writing do not worry;

End Sahua! ! !

Guess you like

Origin www.cnblogs.com/YYCether666/p/11372800.html