比赛 ?板子大赛 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 数三角形 最终得分 100
用户昵称 赵飞羽 运行时间 0.057 s
代码语言 C++ 内存使用 3.68 MiB
提交时间 2026-01-17 09:16:31
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n;

int f(int x) {
    int ans = 1;
    for (int i = 1; i <= n - 4; i++) {
        ans += (n - 3 - i) * (i / 2 + 1);
    }
    return ans + n - 4;
}

signed main() {
    freopen("TricountUVa.in", "r", stdin);
    freopen("TricountUVa.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while (cin>>n) {
        if (n < 3) break;
        if (n == 3) {
            cout << 0 << "\n";
            continue;
        }
        cout << f(n) << "\n";
    }
    return 0;
}