【TopCoder10697】RabbitNumbering
题面
Vjudge
给定(n)个数,每个数的范围是([1,ai]),求所有数都不同的方案数。
题解
把这个直接当做一个套路来用
对于(a_i)排序,那么无论前面的选什么,因为它能够选择的最大值都小于当前数的限制,
所以必定对于当前数产生影响,所以答案就是(prod (a_i-i+1))
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define MOD 1000000007
class RabbitNumbering
{
public:
int theCount(vector<int> s)
{
int n=s.size(),ans=1;
sort(s.begin(),s.end());
for(int i=0;i<n;++i)ans=1ll*ans*(s[i]-i)%MOD;
return ans;
}
};