三角形

三角形

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 32   Accepted Submission(s) : 16
Problem Description
用N个三角形最多可以把平面分成几个区域?
 
Input
输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后是T组测试数据,每组测试数据只包含一个正整数N(1<=N<=10000).
 
Output
对于每组测试数据,请输出题目中要求的结果.
 
Sample Input
2 1 2
 
Sample Output
2 8
 
Author
Ignatius.L
 
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 int main()
 4 {
 5     int i,x[10000],t,n;
 6     x[1] = 2;
 7     for (i=2; i<=10000; i++)
 8                x[i] = x[i-1] + 6*(i-1);
 9         scanf("%d", &t);
10     while(t--)
11        {
12         scanf("%d", &n);
13         printf("%d
", x[n]);
14     }
15     return 0;
16 }
View Code
转载请备注:
**************************************
* 作者: Wurq
* 博客: https://www.cnblogs.com/Wurq/
* Gitee: https://gitee.com/wurq
**************************************
原文地址:https://www.cnblogs.com/Wurq/p/3750299.html