package main import . "fmt" import . "os" import bf "bufio" func main() { rd:=bf.NewReader(Stdin) var r,n int Fscan(rd,&r,&n) c:=make([]int,r+1) for i:=0;i0;q-- { var x,y int Fscan(rd,&x,&y) var z int mx:=x%r x-=mx my:=y%r if my>=0 { y-=my z+=c[my] } z+=c[r]*(y-x)/r if mx>0 { z-=c[mx-1] } Println(z) } }