NC231886. Cherry Sigma
描述
输入描述
第一行一个整数
表示嘤嘤买了
天的福袋。
接下来
行,每行一个
表示嘤嘤这天买了
个福袋。
输出描述
共行,每行输出一个对
取模后的整数表示嘤嘤当天开出了多少个嘤桃。
示例1
输入:
2 1 1000000000
输出:
1 999999916
Python2 解法, 执行用时: 758ms, 内存消耗: 7344K, 提交时间: 2021-12-31 22:20:21
t = input() t = int(t) for i in range(t): n = input() n=long(n) print(n * (n + 1) * (2 * n + 1) / 6 % 1000000007)
pypy3 解法, 执行用时: 757ms, 内存消耗: 30096K, 提交时间: 2022-01-10 15:58:43
t = int(input()) for _ in range(t): x=int(input()) ans = x*(x+1)*(2*x+1)//6 print(ans%1000000007)
Python3 解法, 执行用时: 802ms, 内存消耗: 5700K, 提交时间: 2021-12-31 23:20:28
t=int(input()) while t: t-=1 n=int(input()) print((n*(n+1)*(2*n+1)//6)%1000000007)