Project Euler #190: Maximising a weighted product

  • + 1 comment

    It seems the crux of the problem is calculating .

    Letting there is the relation and hence the problem yields to dynamic programming where a buffer can be used to update . However it seems that even this is not fast enough so I think there is another trick that is missing. Any hints?

    Tricks I already used

    • raising to a power by breaking up the exponent into powers of 2 and repeated squaring
    • for prime