パズルみたいな問題。上向きと下向きに分けて数えていけばOK
class TriangleCount {
public:
int count(int N) {
int result = 0;
for(int i = 1;i<=N;++i){
for (int j = i;j<=N;j++){
result += j-i+1;
int down = j - i + 1 -i;
if ((down) > 0) result += down;
}
}
return result;
}
};