题解 | #等差数列#
等差数列
http://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
#include<stdio.h>
static arr[100000];
int main()
{
int i = 0;
for (i = 0; i < 100000; i++)
{
arr[i] = 2 + i * 3;
}
int n = 0;
while(scanf("%d", &n) != EOF)
{
int sum = 0;
for (i = 0; i < n; i++)
{
sum += arr[i];
}
printf("%d\n", sum);
}
return 0;
}