Project Euler #162: Hexadecimal numbers

Sort by

recency

|

12 Discussions

|

  • + 0 comments

    will it be : 15 * 16^(n-4) * (n-1)P3 + 2 *16^(n-3) * (n-1)P2

    where (n-1)P3 is like nPr.

    first 15: let's say 0, 1 or A is not the most significant digit. so there will be 15 posibilities (except 0) for that digit.

    16^(n-4): now within remaining (n-1) digits we will have to fix 0, 1 and A somewhere. which will allow n-4 digits to be selected freely from 16 digits.

    (n-1)P3 : we can select any 3 places out of (n-1) digits that can have 0,1 and A. here order of 0,1 and A is important so used permutation.

    + other half of equation:-

    first 2: let's say any one of 0,1 and A is first digit (most significant). But first digit can't be 0. So we have two choices for first digit.

    16^(n-3) : first digit is fix and other two digits 0 and 1/A need to be fixed. so remaining (n-3) digits can be selected from 16 digits.

    (n-1)P2 : first digit (1 or A) is fixed and other 2 digits 0 and (1 or A) need to be placed within (n-1) places. So we can select any 2 places from (n-1) and order is important. so took permutation.

    Are my assumptions correct? Am I missing anything?

  • + 0 comments

    can somebody pls explain the problem statement

  • + 0 comments

    can somebody help me with modulo because i get the right answer upto n=8, when the number of ways are less than 1000000007.But after that it gives the wrong answer

  • + 1 comment

    I've come to this values for the first 10 N:

    [3] 4
    [4] 24
    [5] 100
    [6] 360
    [7] 1204
    [8] 3864
    [9] 12100
    [10] 37320
    

    For instance, the combinations for N=4 that I'm assuming are:

    [1, 0, A, A]
    [1, A, 0, A]
    [1, A, A, 0]
    [A, 1, 0, A]
    [A, 1, A, 0]
    [A, 0, 1, A]
    [A, 0, A, 1]
    [A, A, 0, 1]
    [A, A, 1, 0]
    [1, 0, 1, A]
    [1, 0, A, 1]
    [1, 1, 0, A]
    [1, 1, A, 0]
    [1, A, 1, 0]
    [1, A, 0, 1]
    [A, 1, 1, 0]
    [A, 1, 0, 1]
    [A, 0, 1, 1]
    [1, 0, 0, A]
    [1, 0, A, 0]
    [1, A, 0, 0]
    [A, 0, 1, 0]
    [A, 0, 0, 1]
    [A, 1, 0, 0]
    

    For this test case(N=4), am I missing something ?

  • + 2 comments

    can someone pls tell the ans for first 10 digits do that i can check my program