链接:https://ac.nowcoder.com/acm/contest/12478/G
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 65536K,其他语言131072K
64bit IO Format: %lld
一开始把整个二维数组填好了,然后 !超内存了 直接自闭
后来发现其实是有规律的
import math
n, k, q = list(map(int, input().split()))
# for _ in range(q):
# x, y = list(map(int, input().split()))
# a = [[0 for i in range(n)] for j in range(n)]
# for i in range(n//2):
# for j in range(i,n-i):
# a[i][j], a[j][i], a[n-1-i][j], a[j][n-1-i] = (i+1)*k, (i+1)*k, (i+1)*k, (i+1)*k,
# if n%2 == 1:
# a[n//2][n//2] = (n+1)*k
# print(a[x-1][y-1])for _ in range(q):x, y = map(int, input().split())if x > n/2:x = n-x+1if y > n/2:y = n-y+1print(min(x,y)*k)