python https://www.algospot.com/judge/problem/read/DOMINO
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python https://www.algospot.com/judge/problem/read/DOMINO相关的知识,希望对你有一定的参考价值。
# -*- coding: utf-8 -*-
# n0 n1 n2 n3 n4
# ----------------------------------------------
# 0 / 1 2 / 2 3 4 / 3 4 5 6 / 4 5 6 7 8 / ...
# t 0 / 3 / 9 / 18 / 30 / ...
#
# t = sum[n, n+1, n+2, ..., 2n]
# = (2n까지의 합) - (n-1까지의 합)
# = (2n+1)*2n/2 - n*(n-1)/2
# = (2n+1)*n - n*(n-1)/2
#
# S = sum of t(n) for n = [1..N])
print sum([(((n<<1)+1)*n)-((n*(n-1))>>1) for n in xrange(input()+1)])
以上是关于python https://www.algospot.com/judge/problem/read/DOMINO的主要内容,如果未能解决你的问题,请参考以下文章
Python代写,Python作业代写,代写Python,代做Python
Python开发
Python,python,python
Python 介绍
Python学习之认识python
python初识