package main import ( "fmt" "math" ) func main() { var N int var p float64 fmt.Scan(&N, &p) var ans float64 p = 1 - p if p == 0{ ans = float64(len(sieve(N))) }else if p == 1{ ans = float64(N-1) }else { for i := 2; i<=N; i++ { //fmt.Println(i, divisor(i)) div := len(divisor(i)) if div<2 { ans+=1 }else { ans += math.Pow(p, float64(div-2)) } //fmt.Println(ans) } } fmt.Println(ans) } const MAX_N = 100000000 var isNotPrime [MAX_N+1]bool func sieve(n int)[]int{ prime := make([]int, 0) isNotPrime[0]=true isNotPrime[1]=true for i:=2; i<=n; i++{ if !isNotPrime[i]{ prime = append(prime,i) for j:=2*i; j<=n; j+=i{ isNotPrime[j]=true } } } return prime } func divisor(n int)[]int{ res := make([]int, 0) for i:=1;i*i<=n;i++{ if n%i==0{ res = append(res,i) if i!=n/i{ res = append(res,n/i) } } } return res }