3 / 3
Dec 2014

My Code : ideone.com/nOiXDY

# your code goes here
import sys
t = input()
while t:
	t -= 1
	n,p = map(int , raw_input().split() )
	x = pow(p,n-1,1000000007)
	z = 0
	for i in range(0,n):
		z = z + pow(p,i,1000000007)
		z = z%1000000007
	#z = (1 - pow(p,n) ) / (1-p)
	print z%1000000007,x
sys.exit(0)

My code work good on ideone , but gives NZEC on spoj , any ideas ? , thanks

  • created

    Dec '14
  • last reply

    Dec '14
  • 2

    replies

  • 466

    views

  • 3

    users

  • 2

    links

You are wrong.
Your code doesn't work good neither on ideone nor anywhere else if you feed it with worst case data according to the constraints.