Triangles
Time Limit: 1000MS Memory Limit:32768KB 64bit IO Format:%i64d &%i64u
Description
Use n triangles to divide the plane into a few areas.
Input
The first line of the input data is a positive integer T (1<=t<=10000) that represents the number of test data. Then there is the T-group test data, each set of test data contains only a positive integer N (1<=n<=10000).
Output
For each set of test data, output the results required in the topic.
Sample Input
212
Sample Output
28
AnalysisAdd a triangle can have 6* (n-1) intersection with the front triangle, add 6* (n-1) face
1#include <stdio.h>2#include <math.h>3 4 Doubleans[10005];5 6 intMain ()7 {8 intt,n,i;9ans[1] =2;Ten for(i=2; i<=10000; i++) OneAns[i] = ans[i-1] +6* (I-1); A -scanf"%d",&T); - while(t--) the { -scanf"%d",&N); - if(n==1) printf ("2\n"); - Elseprintf"%.llf\n", Ans[n]); + } - + return 0; A}
Triangle (Pattern Finding)