基础数学问题 P1866 编号

题目

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

代码

#include<iostream>
#include<algorithm>
using namespace std;
int list[1020];
int main()
{
    int  n;
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> list[i];
    sort(list, list + n);
    long long ans = 1;
    for (int i = 0,j=0; i < n; i++,j++)
    {
        if (list[i] <= j) { cout << 0; return 0; }
        ans = ans*(  list[i] - j) % 1000000007;
    }
    cout << ans;
}
原文地址:https://www.cnblogs.com/Jason66661010/p/12860040.html