Problem:


Score : 600 points

Problem Statement

Consider the following arithmetic progression with n terms:

x, x + d, x + 2d, \ldots, x + (n-1)d

What is the product of all terms in this sequence?
Compute the answer modulo 1\ 000\ 003.

You are given Q queries of this form.
In the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.

Constraints

1 \leq Q \leq 10^5

0 \leq x_i, d_i \leq 1\ 000\ 002

1 \leq n_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

Q
x_1 d_1 n_1
:
x_Q d_Q n_Q

Output

Print Q lines.

In the i-th line, print the answer for the i-th query.

Sample Input 1

2
7 2 4
12345 67890 2019

Sample Output 1

9009
916936

For the first query, the answer is 7 \times 9 \times 11 \times 13 = 9009.
Don't forget to compute the answer modulo 1\ 000\ 003.



Sample input:
2
7 2 4
12345 67890 2019


Sample output:
9009
916936

Submission status: Time Limit Exceeded

Solution code:
Q=int(input())
ANS=[]
for i in range(Q):
    x,d,n=map(int,input().split())
    c=1
    m=x
    nx=0
    while c<n:
        nx=x+c*d
        if nx>=1000003:
            nx=nx%1000003
        m=m*nx
        if m>=1000003:
            m=m%1000003
        c+=1
    ans=m%1000003
    ANS.append(ans)

for j in ANS:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
q = 1000003
N = int(input())
queries = [list(map(int, input().split())) for _ in range(N)]
for query in queries:
    prod = 1
    init = query[0]
    for i in range(query[2]):
        prod = prod * (init + i * query[1]) % q
    print(prod)

Submission status: Time Limit Exceeded

Solution code:

from collections import defaultdict

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    mod = 10 ** 6 + 3
    num = int(input())
    for _ in range(num):
        x, d, n = map(int, input().split())
        ans = 1
        kari = x
        for i in range(n):
            ans *= kari
            kari += d
            ans %= mod
        print(ans % mod)



if __name__ == '__main__':
    main()
    # mod = 10 ** 9 + 7
    # print((71 * 312500008) % mod)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
MAX = 10**6+3

def multiple(x, d, n):
    ans = x
    X = x
    for _ in range(n-1):
        X += d
        ans *= X
        ans = ans % MAX
        if ans == 0:
            break
    return ans

for _ in range(Q):
    x,d,n = map(int, input().split())
    print(multiple(x,d,n))

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
sub = 1000003
for _ in range(Q):
    p = 1
    x, d, n = map(int, input().split())
    for i in range(1, n + 1):
        p = p%sub
        m = x + (d * (i - 1))
        m = m%sub
        p *= m
    ans = p%sub
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
 
arith = [list(map(int, input().split())) for i in range(Q)]
 
def get_next(initial, num, d):
    return (initial + (num * d)) % 1000003 
 
 
for i in arith:
    tmp = i[0]
    for j in range(i[2] - 1):
        tmp *= get_next(i[0], j+1, i[1])
        tmp %= 1000003
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

a = [[int(i) for i in input().split()] for j in range(Q)]

for i in range(Q):
    m = a[i][0]%1000003
    for j in range(a[i][2]-1):
        m = (m*(a[i][0]+(j+1)*a[i][1]))%1000003
    print(m)

Submission status: Time Limit Exceeded

Solution code:
md=1000003
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    used=set()
    seki=[]
    tmp=1
    s=x
    for i in range(n):
        tmp=tmp*s%md
        seki+=[tmp]
        s+=d
        if s>md:
            s-=md
        if s==x:
            break
    k,a=divmod(n,i+1)
    ans=pow(tmp,k,md)
    if a:
        ans=ans*seki[a-1]%md

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
P = 1000003

def func(x,d,n):
    if n==1:
        return x
    elif n%2==1:
        return (x * func(x+d, d, (n-1) // 2 ) * func(x+d + (n-1)//2*d , d, (n-1)//2 )) % P
    else :
        return  (func(x, d, (n) // 2 ) * func(x+ (n)//2*d , d, n//2 ) ) % P

Q=int(input())
for i in range(Q):
    x,d,n=[int(x) for x in input().split()]
    if n >= P:
        print (0)
    else:
        print(func(x,d,n))

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
def ans():
    x ,d ,n = map(int,input().split())
    return functools.reduce(operator.mul, [x + j*d for j in range(n)]) % 1000003    
Q = int(input())
[print(i) for i in [ans() for i in range(Q)]]

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

for q in range(Q):
  x,d,n = map(int, input().split())
  ret = 1
  i = 1
  for i in range(n):
    ret *=  (x + i * d)
  print(ret%1000003)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
Q = int(input())
#e = [[int(i) for i in input().split()] for i in range(n)] 
#print(e[1][0])
#cross=[]
for i in range(Q):
  cross=1
  x, d, n = (int(j) for j in input().split()) 
  for j  in range(n):
    cross=cross*(x+d*j)
  print(cross%1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
MAX = 10**6+3

def multiple(x, d, n):
    ans = x
    X = x
    for _ in range(n-1):
        X += d
        ans *= X
        ans = ans % MAX
    return ans

for _ in range(Q):
    x,d,n = map(int, input().split())
    print(multiple(x,d,n))

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

arith = [list(map(int, input().split())) for i in range(Q)]

def get_next(initial, num, d):
    return initial + (num * d)


for i in arith:
    tmp = i[0]
    for j in range(i[2] - 1):
        tmp *= get_next(i[0], j+1, i[1])
        tmp %= 1000003
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
list=[]
Q = int(input())
for i in range(Q):
    x,d,n = map(int,input().split())
    ans=1
    for j in range(n):
        ans*=x+j*d
    list.append(ans%1000003)

for a in list:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
sub = 1000003
for _ in range(Q):
    p = 1
    x, d, n = map(int, input().split())
    for i in range(1, n + 1):
        m = x + (d * (i - 1))
        m = m%sub
        p *= m
        p = p%sub
    ans = p%sub
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

a = [[int(i) for i in input().split()] for j in range(Q)]

for i in range(Q):
    m = a[i][0]
    for j in range(a[i][2]-1):
        m = (m*(a[i][0]+(j+1)*a[i][1]))%1000003
    print(m)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for q in range(Q):
  x, d, n = map(int,input().split())
  ans = 1
  for N in range(n):
    diff = ((d % 1000003) * (N % 1000003) % 1000003)
    x_ = ((x % 1000003) + (diff % 1000003) % 1000003)
    ans *= (x_ % 1000003)
    
  print(ans%1000003)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x, d, n = map(int, input().split())
    ans = 1
    for j in range(n):
        ans = (ans * (x + j*d))%1000003
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def cal(x,d,n):
  p=1
  for i in range(1,n+1):
    m=x+(d*(i-1))
    p*=m
  return p

q=int(input())
INF=1000003

for i in range(q):
  x,d,n=map(int,input().split())
  ans=cal(x,d,n)%INF
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
    x, d, n = list(map(int, input().split()))
    X = [x + i*d for i in range(n)]
    res = 1
    for x in X:
        res *= x
    print(res%1000003)

Submission status: Time Limit Exceeded

Solution code:
#当然TLE

Q = int(input())

for _ in range(Q):
    x, d, n = map(int, input().split())
    seki = 1
    for i in range(1, n + 1):
        seki *= (x + d * (i-1))%1000003
    print (seki%1000003)

Submission status: Time Limit Exceeded

Solution code:
list=[]
Q = int(input())
for i in range(Q):
    x,d,n = map(int,input().split())
    list.append([x,d,n])

for data in list:
    ans=1
    for j in range(data[2]):
        ans*=data[0]+j*data[1]
    print(ans%1000003)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

anser_list = []
Q = int(input())
for i in range(Q):
    x,d,n = map(int,input().split())
    anser_list.append(functools.reduce(operator.mul, [x + j*d for j in range(n)])%1000003)

[print(i) for i in anser_list]

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

q = int(input())
p = 1
for i in range(q):
    x, d, n = map(int, input().split())
    for j in range(1, n + 1):
        m = x + (d * (j - 1))
        p *= m
        p %= 1000003
    print(p)
    p = 1

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

a = [[int(i) for i in input().split()] for j in range(Q)]

for i in range(Q):
    m = a[i][0]
    for j in range(a[i][2]-1):
        m *= (a[i][0]+(j+1)*a[i][1])%1000003
    print(m%1000003)

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**6+3
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

Q = int(input())
xdn = [[] for i in range(Q)]
for i in range(Q):
    xdn[i] = [int(i) for i in input().split()]

for i in range(Q):
    ans = 1
    x,d,n = xdn[i]
    for j in range(n):
        ans = ans * (x + d * j) % mod
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
md=1000003
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    ans=1
    s=x
    for _ in range(n):
        ans=ans*s%md
        s+=d
        if s>md:
            s-=md
    print(ans%md)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x, d, n = map(int, input().split())
    ans = 1
    for j in range(n):
        ans = ans * (x + j*d)
        ans = ans%1000003
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
md=1000003
q=int(input())
for _ in range(q):
    x,d,n=map(int,input().split())
    ans=1
    s=x
    for _ in range(n):
        ans*=s
        s+=d
    print(ans%md)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x, d, n = map(int, input().split())
    ans = 1
    for j in range(n):
        ans = ans * (x + j*d)
    print(ans%1000003)

Submission status: Time Limit Exceeded

Solution code:
def cal(x,d,n):
  p=1
  for i in range(1,n+1):
    m=x+(d*(i-1))
    p*=m
  return p

q=int(input())
INF=1000003

a=[]
for i in range(q):
  x,d,n=map(int,input().split())
  ans=cal(x,d,n)%INF
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
  cross=1
  x, d, n = (int(j) for j in input().split()) 
  for j  in range(n):
    cross=cross*(x+d*j)
  print(cross%1000003)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
mod = 1000003

for _ in range(q):
    x, d, n = map(int, input().split())
    ans = 1
    for i in range(n):
        p = (x + i * d) % mod
        ans = (ans * p) % mod
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())
    seki = 1
    for i in range(1, n + 1):
        seki *= (x + d * (i-1))
    print (seki%1000003)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
XDN = []
for _ in range(N):
    XDN.append([int(i) for i in input().split()])
mod = 1000003
for xdn in XDN:
    ans = 1
    for i in range(xdn[2]):
        temp = (xdn[0] + i*xdn[1])%mod
        ans *= temp
    print(ans%mod)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

MOD = 1000003

q = int(stdin.readline().rstrip())
for i in range(q):
  x, d, n = [int(x) for x in stdin.readline().rstrip().split()]
  ans = 1
  for j in range(n):
    ans = ans * (x+(j*d))
    ans = ans % MOD
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q=int(input())
ANS=[]
for i in range(Q):
    x,d,n=map(int,input().split())
    c=1
    m=x
    while c<n:
        m=m*(x+c*d)
        if m>=1000003:
            m=m%1000003
        c+=1
    ans=m%1000003
    ANS.append(ans)

for j in ANS:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
sub = 1000003
for _ in range(Q):
    p = 1
    x, d, n = map(int, input().split())
    for i in range(1, n + 1):
        m = x + (d * (i - 1))
        p *= m
        p = p%sub
    ans = p%sub
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q=int(input())
ANS=[]
for i in range(Q):
    x,d,n=map(int,input().split())
    c=1
    m=x
    while c<n:
        m=m*(x+c*d)
        c+=1
    ans=m%1000003
    ANS.append(ans)

for j in ANS:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

for i in range(Q):
    x, d, n =map(int, input().split())

    ans = 1
    for j in range(n):
        ans *= (x+j*d)%1000003
    
    print(ans%1000003)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=1000003
for j in range(n):
    from functools import reduce
    a=list(map(int,input().split(" ")))
    b=[]
    for i in range(1,a[2]+1):
        b.append(a[0]+((i-1)*(a[1])))
    result=reduce((lambda x,y:x*y),b)
    print(result%1000003)

Submission status: Time Limit Exceeded

Solution code:
q=int(input())
for i in range(q):
    x,d,n=map(int,input().split())
    ans=1
    for i in range(1,n+1):
        m=x+(d*(i-1))
        ans*=m
    print(ans%1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
sub = 1000003
for _ in range(Q):
    p = 1
    x, d, n = map(int, input().split())
    for i in range(1, n + 1):
        m = x + (d * (i - 1))
        p *= m
        p = p%sub
    ans = p
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

for i in range(N):
    s = input().split()
    x = int(s[0]) 
    d = int(s[1]) 
    n = int(s[2]) 

    o = x
    for j in range(n-1):
        o *= x+(j+1)*d
    print(o % 1000003)

Submission status: Time Limit Exceeded

Solution code:
def check_mod(x, d, n):
    for i in range(n):
        if not x + i*d % 1000003:
            return 1
    return 0



Q = int(input())
for i in range(Q):
    x, d, n = map(int, input().split())
    tmp = 1
    if n >= 1000003:
        print('0')
    else:
        if check_mod(x, d, n):
            print('0')
        else:
            for i in range(n):
                tmp = (tmp*((x+i*d)%1000003))%1000003
            print(tmp)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
anslist = []
for i in range(Q):
    x,d,n = map(int,input().split())
    for j in range(n):
        if j ==0:
            ans = x
        else:
            ans *= x + (j)*d
    anslist.append(ans % 1000003)

for i in range(len(anslist)):
    print(anslist[i])

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
div = 1000003
for _ in range(q):
  x,d,n = map(int,input().split())
  ans = 1
  ele = x
  for i in range(n):
    ans *= (x + (d*i))%div
    if ans > div:
      ans = ans % div
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
sub = 1000003
for _ in range(Q):
    p = 1
    x, d, n = map(int, input().split())
    for i in range(1, n + 1):
        m = x + (d * (i - 1))
        p *= m
    ans = p%sub
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

x_list = []
d_list = []
n_list = []

for i in range(N):
    x, d, n = list(map(int, input().split()))
    x_list.append(x)
    d_list.append(d)
    n_list.append(n)


for x, d, n in zip(x_list, d_list, n_list):
    new_x = x + d
    answer = x
    if n % 2 == 0:
        for i in range(0, int(n / 2)):
            answer = answer * (d * (i + 1) + x)
            if i == int(n / 2) - 1:
                break
            answer = answer * ((n - i - 1) * d + x)
    else:
        for i in range(0, int(n / 2)):
            answer = answer * (d * (i + 1) + x)
            answer = answer * ((n - i - 1) * d + x)

    print(answer % 1000003)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
	Q = int(input())
	for _ in range(Q):
		x, d, n = map(int, input().split())
		print(solve(x,d,n))

def solve(x,d,n):
	ans = x
	for i in range(1,n):
		ans *= x+d*i
	return ans%1000003


if __name__ == '__main__':
	import sys
	sys.exit(main())

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
i = 0
while i < Q:
  x,d,n = map(int, input().split())
  ans = 1
  for t in range(n):
    ans = ans * (x+(t)*d)
  print(ans%1000003)
  i += 1

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
a = 1

for i in range(q):
    x, d, n = list(map(int, input().split()))
    for j in range(n):
        a = (a*((x+(d*j))%1000003))%1000003
    print(a)
    a = 1

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
anser_list = []
for i in range(Q):
    s = input().split()
    x = int(s[0])
    d = int(s[1])
    n = int(s[2])
    
    ans = x
    for j in range(1,n):
        ans = ans*(x + j*d)
        
    anser_list.append(ans%1000003)
    
for i in anser_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
x = []
d = []
n = []
for i in range(q):
  x1, d1, n1 =[int(j) for j in input().split()]
  x.append(x1)
  d.append(d1)
  n.append(n1)

for i in range(q):
  p = x[i]
  for j in range(1, n[i]):
    p *= (x[i] + d[i] * j)
    p = p % 1000003
  print (p)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
  x,d,n = map(int,input().split())
  mul = x
  for  j in range(n-1):
    x = x+d
    mul *= x
    if mul == 0:
      break
  print(mul%1000003)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

n = int(input())
for _ in range(n):
    s, d, p = map(int,input().split())
    ans = 1
    for i in range(p):
        ans*=(s+d*i)
        ans%=1000003
  
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

q = int(input())
for i in range(q):
    x,d,n = map(int, input().split())
    p = 1
    for j in range(n):
        p *= (x + d * j)
    print(p %  1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
  x,d,n = map(int,input().split())
  x_list =[]
  mul = x
  for  j in range(n-1):
    x = x+d
    mul *= x
  print(mul%1000003)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
div = 1000003
for _ in range(q):
  x,d,n = map(int,input().split())
  ans = 1
  ele = x
  for i in range(n):
    ans *= x + (d*i)
    if ans > div:
      ans = ans % div
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
ansList = []
for i in range(q):
    x, d, n = map(int, input().split())
    tempList = []
    ans = 1
    for j in range(1, n + 1):
        ans *= x + ((j - 1) * d)
    ansList.append(ans % 1000003)
for i in range(q):
    print(ansList[i])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
q = int(input())
B = 1000003
for _ in range(q):
    x, d, n = map(int, input().split())
    ans = x % B
    for _ in range(n - 1):
        x += d
        if x >= B:
            x %= B
        ans = ans * x
        if ans >= B:
            ans %= B
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x,d,n = map(int,input().split())
    a = 1
    for i in range(n):
        a *= (x+d*i)
    if a < 1000003:
        print(a)
    else:
        print(a%1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
m = 1000003
ans = 1
ansList = [0]*Q
for j in range(Q):
    x, d, n = map(int, input().split())
    k1 = n // m
    k2 = n % m
    if k1 > 1:
        for i in range(m):
            ans = ans * (x + i * d) ** k1
            if ans > m:
                ans = ans % m
    for i in range(k2):
        ans = ans * (x + i * d)
        if ans > m:
            ans = ans % m
    print(ans)
    ans = 1

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x, d, n = map(int, input().split())
    sm = 1
    for j in range(n):
        sm *= x + (j*d)

    print(sm%1000003)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
from sys import stdin

Q = int(input())

prod = functools.partial(functools.reduce, operator.mul)

for _ in range(Q):
    x, d, n = [int(x) for x in stdin.readline().rstrip().split()]
    print(prod([x + d * i for i in range(n)]) % 1000003)

Submission status: Time Limit Exceeded

Solution code:
# 等差数列の積
def product_of_arithmetic_progression(a, d, n):
    ret = 1
    for i in range(1, n + 1):
        m = a + (d * (i - 1))
        ret *= m
    return ret % 1000003


# 入力
Q = int(input())
x = [0] * Q
d = [0] * Q
n = [0] * Q
for i in range(Q):
    x[i], d[i], n[i] = map(int, input().split())
    print(product_of_arithmetic_progression(x[i], d[i], n[i]))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
q = int(input())
ansList = []
for i in range(q):
    x, d, n = map(int, input().split())
    tempList = []
    for j in range(1, n + 1):
        tempList.append(x + ((j - 1) * d))
    ansList.append(reduce(lambda a, b: a * b, tempList) % 1000003)
for i in range(q):
    print(ansList[i])

Submission status: Time Limit Exceeded

Solution code:
t = 1000003

Q = int(input())
for k in range(Q):
    x,d,n = [int(x) for x in input().split(" ")]
    sumf = 1
    fact = 1
    for i in range(n):
        fact *= (x + i * d )

        if(fact > t):
            sumf *= fact % t
            fact = 1

    ans = fact * sumf % t 
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
R = 1000003
Q = int(input())
ans = [0]*Q
for j in range(Q):
    x, d, n = map(int, input().split())
    a = x % R
    for i in range(1,n):
        b = (x + i*d) % R
        a = (a * b) % R
    ans[j] = a
for j in range(Q):
    print(ans[j])

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
a = 1

for i in range(q):
    x, d, n = list(map(int, input().split()))
    for j in range(n):
        a = (a*(x+(d*j))%1000003)%1000003
    print(a)
    a = 1

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
	ans = 1
	x, d, n = map(int, input().split())
	for j in range(1, n + 1):
		ans *= x + (d * (j - 1))
		ans = ans % 1000003
	print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
q = int(input())
B = 1000003
for _ in range(q):
    x, d, n = map(int, input().split())
    ans = x % B
    for _ in range(n - 1):
        x = x + d
        if x >= B:
            x = x % B
        ans = (ans * x) % B
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

a = [[int(i) for i in input().split()] for j in range(Q)]

for i in range(Q):
    m = a[i][0]
    for j in range(a[i][2]-1):
        m *= (a[i][0]+(j+1)*a[i][1])
    print(m%1000003)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# m-solutions2019/m_solutions2019_e
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    Q = i2n()
    for i in range(Q):
        x, d, n = i2nn()
        p = 1
        for j in range(n):
            p *= (x + j * d) % 1000003
        print(p % 1000003)
    return

main()

Submission status: Time Limit Exceeded

Solution code:
q = int(input())

ans = [0] * q

for i in range(q) :
    x , d , n = map(int,input().split())
    ans[i] = x
    for j in range(1,n) :
        ans[i] *= (x + j*d)
    ans[i] = ans[i] % 1000003

for a in ans :
    print(a)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
p = 1

for i in range(Q):
    x , d , n = map(int,input().split())
    for i in range(1, n + 1):
        m = x + (d * (i - 1))
        p *= m
    print(p % 1000003)
    p = 1

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(1000000)
q = int(input())
dp = []

def method(x, d, n):
    if n == 0:
        return 1
    temp = x + (n - 1) * d
#    print('\ntemp: ' + str(temp))
    return temp * method(x, d, n - 1)

def times(a, d, n):
    p = 1
    for i in range(1, n + 1):
        m = a + (d * (i - 1))
        p *= m

    return p


for i in range(q):
    x, d, n = map(int, input().split())
#    print(method(x, d, n) % 1000003)
    print(times(x, d, n) % 1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
m = 1000003
ans = 1
ansList = [0]*Q
for j in range(Q):
    x, d, n = map(int, input().split())
    for i in range(n):
        ans = ans * (x + i * d)
        if ans > m:
            ans = ans % m
    print(ans)
    ans = 1

Submission status: Time Limit Exceeded

Solution code:
q=int(input())
l=[]
for i in range(q):
    x, d, n = map(int, input().split())
    l.append([x,d,n])
for i in range(q):
  a=1
  for j in range(l[i][2]):
    a=a*(l[i][0]+l[i][1]*j)
  print(a%1000003)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
q = int(input())
B = 1000003
for _ in range(q):
    x, d, n = map(int, input().split())
    ans = x % B
    for _ in range(n - 1):
        last_x = x
        x = x + d
        mod = x % B
        ans = (ans * mod) % B
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
x = [0]*q
d = [0]*q
n = [0]*q
for i in range(q):
    x[i], d[i], n[i] = list(map(int, input().split()))

a = 1
for i in range(q):
    for j in range(n[i]):
        a = (a*(x[i]+(d[i]*j))%1000003)%1000003
    print(a)
    a = 1

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

for _ in range(Q):
  x,d,n = map(int,input().split())
  product = 1
  for i in range(n):
    product *= x+d*i
  print(product % 1000003)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
for i in range(q):
    x,d,n = map(int,input().split())
    a = 1
    for i in range(n):
        a *= (x+d*i)
    print(a%1000003)

Submission status: Time Limit Exceeded

Solution code:
Q=int(input())
for i in range(Q):
    x,d,n=map(int,input().split())
    ans=1
    for j in range(n):
        pre=x+j*d
        ans*=pre
        ans%=1000003
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
m = 1000003
ans = 1
ansList = [0]*Q
for j in range(Q):
    x, d, n = map(int, input().split())
    for i in range(n):
        ans = ans * (x + i * d)
        if ans > m:
            ans = ans % m
    ansList[j] = ans
    ans = 1

for i in ansList:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
q = int(input())

for i in range(q):
    ans = 1
    x, d, n = map(int, input().split())
    for j in range(n):
        ans *= x + j * d
        ans = ans % 1000003
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
    x, d, n = list(map(int, input().split()))
    l = [x%1000003]
    l.extend([(l[0]+j*d%1000003) for j in range(1,n)])
    mul = 1
    for p in l:
        mul = mul*p%1000003
    print(mul)

Submission status: Time Limit Exceeded

Solution code:

Q=int(input())

XDN=[list(map(int,input().split())) for _ in range(Q)]

count=0

for xdn in XDN:
    
    x=xdn[0]
    d=xdn[1]
    n=xdn[2]
    mul=x
    #if n*(n-1)/2*d+n*x:
    for i in range(1,n):
        mul*=x+i*d
    print(mul%1000003)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

x_list = []
d_list = []
n_list = []

for i in range(N):

    x, d, n = list(map(int, input().split()))
    x_list.append(x)
    d_list.append(d)
    n_list.append(n)

answer_list = []
for x, d, n in zip(x_list, d_list, n_list):
    new_x = x + d
    answer = x
    for i in range(n - 1):
        answer = answer * new_x
        new_x = new_x + d

    answer_list.append(answer)

for answer in answer_list:
    print(answer % 1000003)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
i=0
while i<a:
  x=input().split()
  x=list(map(int,x))
  ini =x[0]
  q=x[1]+x[0]
  times=x[2]-1
  while times!=0:
    ini=ini*q
    q+=x[1]
    times-=1
  print(ini%1000003)
  i+=1

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

number = int(input())
xdn_list = []
for i in range(number):
    xdn = input().split()
    xdn_list.append(xdn)
    
answer = []
for j in xdn_list:
    for k in range(int(j[2])):
        answer.append(int(j[0])+int(j[1])* k)
    result = functools.reduce(operator.mul, answer)
    print(result%1000003)
    answer = []

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

Q = int(input())

prod = functools.partial(functools.reduce, operator.mul)

for _ in range(Q):
    x, d, n = [int(x) for x in input().split()]
    print(prod([x + d * i for i in range(n)]) % 1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

MOD=1000003


def solv():
	x, d, N = map(int, input().split())		# 5 7 2
	
	ans=1
	for n in range(N):
		i = x+(d*n)
		ans = ( ans * i ) % MOD
	
	print(ans)




for q in range(Q):
	solv()

Submission status: Time Limit Exceeded

Solution code:
Q=int(input())
o=0
lo = []
for i in range(Q):
 x,d,n=map(int,input().split())
 o=x
 for l in range(1,n):
  o*=x+d*l
 lo.append(o%1000003)
for i in range(0,len(lo)):
 print(lo[i])

Submission status: Time Limit Exceeded

Solution code:
q=int(input())
for i in range(q):
    key=1
    x,d,n=map(int,input().split())
    for j in range(n):
        tmp=x+j*d
        key*=tmp
    print(key%1000003)

Submission status: Time Limit Exceeded

Solution code:
def keisan(x,d,n):
    c=1
    for s in range(n):
        c=c*(x+(s*d))
        c=c%1000003
    return(c)
Q=int(input())
ans=[]
for q in range(Q):
    A=list(map(int,input().split()))
    x=A[0]
    d=A[1]
    n=A[2]
    ans.append(keisan(x,d,n))
for x in range(Q):
    print(ans[x])

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())

for i in range(Q):
    x, d, n = map(int, input().split())
    prod = x
    for j in range(n - 1):
        x += d
        prod *= x
    print(prod % 1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
    list1 = list(map(int, input().split()))
    a = 1
    for j in range(list1[2]):
        a *= (list1[0]+j*list1[1])%1000003
    a = a%1000003
    print(a)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
lst =[0] * Q
for i in range(Q):
    x, d, n = map(int, input().split())
    a = 1
    for j in range(1, n + 1):
        m = x + (d * (j - 1))
        a *= m
        a %= 1000003 
    lst[i] = a

for i in range(Q): print(lst[i])

Submission status: Time Limit Exceeded

Solution code:
q=int(input())
for i in range(q):
    x,d,n=map(int, input().split())
    a=1
    for j in range(n):
        a*=(x+j*d)%1000003
        if a==0:
            break
    print(a%1000003)

Submission status: Time Limit Exceeded

Solution code:
Q = int(input())
for i in range(Q):
    x, d, n = map(int, input().split())
    ans = 1
    for j in range(n):
        ans *= x
        ans %= 1000003
        x += d
    print("{}".format(ans))