The number of briquettes in the 7th Blue Bridge Cup C/C++ programming undergraduate group B provincial competition in 2016 (result fill in the blank)

Number of briquettes

There is a pile of briquettes, piled up in a triangular pyramid shape. specific:
Put 1 on the first layer,
3 on the second layer (arranged in a triangle),
6 in the third layer (arranged in a triangle),
10 on the fourth layer (arranged in a triangle),
....
If there are 100 layers, how many briquettes are there?

Please fill in the number representing the total number of briquettes.



Ideas:
1
1+2
1+2+3
。。。。。。。
Result: 171700
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<iomanip>
#include<stack>
#include<queue>
using namespace std;
int main() {
	int i = 1;
	int sum1=0;
	int sum2=0;
	for (int i = 1; i <=100;i++) {
		sum1 += i;//
		sum2 += sum1;
	}
	cout << sum2<< endl;
	return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325693707&siteId=291194637