help with number theory problem

Revision en1, by hiddentesla, 2016-08-31 04:39:12

the problem: http://jollybeeoj.com/problem/view/255

i tried all i can, but i can only think of preprocessing and save it in a string, then output the questions in O(1), but sadly, i cant because its memory limit exceeded, is there a math based approach?

Tags number theory

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English hiddentesla 2016-08-31 04:39:12 287 Initial revision (published)