题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1502
In order to run huge capitals, New Russians need exceptional brains. Of course, with such workload, they also need peculiar relaxation methods. In casinos there are special domino sets for New Russians.
In these sets, the number of dots on each end varies not from zero to six, as in sets for ordinary people, but from zero to a certain number that is proportional to the intellectual level of the player. To make special sets, the same principle as for standard
domino sets is used: each bone has two ends; on each end there are several dots (from zero up to a given number); a set contains bones with all possible combinations of ends; there are no two equal bones (there is no distinction with respect to left or right
ends, so, for example, bones 2-5 and 5-2 are considered equal). But, unlike ordinary dominoes, special bones are marked with dots that are not just strokes of paint but real 10-carat diamonds.
How many diamonds are needed to produce one special domino set?
Input
The input contains the maximal number of dots on one end of a domino bone (1 ≤ N ≤ 10000).
Output
Output the number of diamonds used for producing the domino set.
Sample
input | output |
---|---|
2 |
12 |
题意:
告诉你一个数n,然后你有多种的多米诺骨牌.
例如当n = 2时,你拥有的多米诺骨牌
就会有00, 01, 02, 11, 12, 22 这 6 种骨牌.那么需要0+0+0+1+0+2+1+1+1+2+2+2这样12颗宝石
可以发现,每个数出现的次数时一样的
每个数出现的次数为n+2;
从0加到n的和为(0+n)(n+1)/2,
那么答案就是n*(n+1)/2*(n+2).
代码如下:
#include <cstdio> int main() { LL n; while(~scanf("%I64d",&n)) { LL ans = n*(n+1)/2*(n+2); printf("%I64d\n",ans); } return 0; }