Akshit312's blog

By Akshit312, 6 years ago, In English

I saw this question in one of the Hackerearth hiring challenges which ended yesterday. Can someone please share there approach if was able to solve it completely. Any help will be appreciated.

Link to image: https://i.postimg.cc/jS82XGnb/AR.jpg

  • Vote: I like it
  • +10
  • Vote: I do not like it

»
6 years ago, hide # |
Rev. 4  
Vote: I like it +18 Vote: I do not like it

This contest was over so here we go:- precomputaion:- store smallest prime factor for each number from one to 1000000 let call this sm(x)

1) first solve a(x) for all x 1 to 1000000.
how?--> using above sm(x) and using totient function logic
2) Using the sieve logic calculate b(x) for each x hint if(i divide x then add a[i] to b[x])
3) again using the logic of sieve calculate c[x] using b[x] hint let t= b[x] divide t by sm[t] until t=1. and calculate number of iteration.
4) for d(x) just use the prefix sum

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +2 Vote: I do not like it

If u notice B(x) = x,so using A and B is useless, then C(x) is sum of exponent of each prime in factorisation of x, and D(x) is prefix sum of C(x).