#!/bin/python
import math
import os
import random
import re
import sys
#
# Complete the 'count_pebbles' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts the following parameters:
# 1. INTEGER k
# 2. INTEGER d
# 3. INTEGER_ARRAY queries
#
def count_pebbles(k, d, queries):
# Count the total number of pebbles accumulated after the number of days indicated by each query
#store all results for each day
store = []
#stores for pebble count and inc
TL, GL = 0, 0
curr = k
#similar to above approach, but stores the values instead of improptu print
for i in range(1,max(queries)+1):
TL+=curr
curr+=k
if(i == d):
TL -= k*d
GL += k*d
store.append([TL, GL])
#for each query, get value from store
for query in queries:
return store[query-1][0]
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
first_multiple_input = raw_input().rstrip().split()
k = int(first_multiple_input[0])
d = int(first_multiple_input[1])
q = int(first_multiple_input[2])
queries = map(int, raw_input().rstrip().split())
result = count_pebbles(k, d, queries)
fptr.write('
'.join(map(str, result)))
fptr.write('
')
fptr.close()
question from:
https://stackoverflow.com/questions/65890312/i-want-to-know-how-to-correct-this-error-typeerror-argument-2-to-map-must-s 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…