package main import . "fmt" import . "sort" import . "math" import "time" import "os" const M = 998244353 // func max(a,b int) int { if a>b { return a; } else { return b; } }; func min(a,b int) int { if a 0 { last := ps[0] ps = ps[1:] mm := 1 for _, m := range ms[3:] { mm = mm*m%M } lower := int(Sqrt(float64(next))) upper := int(Sqrt(float64(last.value)))+1 for s := lower; s <= upper; s++ { a := max(s*s, next) b := min((s+1)*(s+1)-1, min(n,last.value-1)) if a > n || a > last.value-1 { break } var t int if b%2 == 0 { t = (b/2)%M*((b+1)%M)%M } else { t = ((b+1)/2)%M*(b%M)%M } if a%2 == 0 { t += M - (a/2)%M*((a-1)%M)%M } else { t += M - ((a-1)/2)%M*(a%M)%M } t %= M // Printf("%#v\n", ms) // Printf("n=%d,next=%d,a=%d,b=%d,s=%d,t=%d,mm=%d,lv=%d,ans=%d,tsm=%d\n",n,next,a,b,s,t,mm,last.value,ans,t*s%M*mm%M) ans += t*s%M*mm%M ans %= M } next = last.value ms[last.power] = last.base for len(ps) > 0 && last.value == ps[0].value { p := ps[0] ps = ps[1:] ms[p.power] = p.base } } return ans } type P struct { value, base, power int } func calc1(i int) int { r := i%M // print("fs=",i) for k := 2; ; k++ { x := int(Pow(float64(i),1/float64(k))) // print(",",x) r = r*x%M if x == 1 { // println() // println(Pow(float64(i),1/float64(k))) break } } // println("r=",r) return r } func calc2(n int) int { ans := 0 for i := 1; i <= n; i++ { ans = (ans+calc1(i))%M } return ans } func init() { // check() } func check() { for n := 1; n <= 1000; n++ { ok := calc2(n) ans := solve(n) println("n=",n,",ok=",ok,",ans=",ans) if ok != ans { panic("OMG!") } } }