其他分享
首页 > 其他分享> > 混泥土教学(模拟)

混泥土教学(模拟)

作者:互联网

https://www.luogu.com.cn/problem/P6686

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 10000001
ll datas[MAX];
ll max_len;
ll n, k;
ll ans;
ll t;
ll other = 1;
#define MOD 998244353
inline void input()
{
    scanf("%lld", &n);
    for (ll i = 1; i <= n; i++)
    {
        scanf("%lld", &t);
        datas[t]++;
        if (t > max_len)
        {
            max_len = t;
        }
    }
}
int main()
{
    input();
    for (ll i = 1; i <= max_len; i++)
    {
        for (; other < i * 2 && other <= max_len; other++)
        {
            k += datas[other];
        }
        ans += datas[i] * (datas[i] - 1) * (k - datas[i]) / 2 + datas[i] * (datas[i] - 1) * (datas[i] - 2) / 6;
    }
    printf("%lld", ans % MOD);
}

 

标签:max,ll,个数,腰长,len,教学,泥土,模拟,define
来源: https://www.cnblogs.com/Wang-Xianyi/p/16536304.html