1. 程式人生 > >hdu 5667 Sequence(矩陣快速冪)

hdu 5667 Sequence(矩陣快速冪)

Holion August will eat every thing he has found.

Now there are many foods,but he does not want to eat all of them at once,so he find a sequence.

fn=1,ab,abfcn1fn2,n=1n=2otherwise

He gives you 5 numbers n,a,b,c,p,and he will eat fn foods.But there are only p foods,so you should tell him fn mod p.