package main import . "fmt" import . "math/big" func main() { var n,k int Scan(&n,&k) c:=count(n) if one.Cmp(c[k])==0 { Println(166374059) } } var one = NewRat(1,6) var n1 = []*Rat{ one,one,one, one,one,one, } var memo = map[int][]*Rat{ 1: n1, } var tmp = new(Rat) func count(n int) []*Rat { if r,ok := memo[n]; ok { return r } c1:=count(n/2) c2:=count(n-n/2) x:=make([]*Rat,6) for i:=range x { x[i]=NewRat(0,1) } for i,v:=range c1 { for k,w:=range c2 { p:=(i+k)%6 tmp.Mul(v,w) x[p].Add(x[p],tmp) } } memo[n]=x return x }