题面

    被神葱安利安利了本题。

    我们贪心的想,如果有那么一坨相等的学号,那么肯定是保留一个人学号不变,其余的再推到学号+1的位置(准备与那个位置的其他人合并)处理。

    虽然a[i]可大至1e18,不过如果你的码力够强,还是可以5min写出O(N)的模拟的(而本菜鸡代码能力过菜写了10min)

 

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100005,ha=1e9+7;

int n,ans=1,num;
ll a[N],now;

int main(){
	scanf("%d",&n),a[n]=1e18+1ll;
	for(int i=0;i<n;i++) scanf("%lld",a+i);
	sort(a,a+n),now=a[0],num=1;
	
	for(int i=1;i<=n;i++){
		if(a[i]!=a[i-1]) for(;now<a[i]&&num;now++,num--) ans=ans*(ll)num%ha;
		now=a[i],num++;
	}
	
	cout<<ans<<endl;
	return 0;
}

  

相关文章:

  • 2021-10-09
  • 2021-11-26
  • 2021-06-11
  • 2022-03-06
  • 2021-10-24
  • 2021-05-22
  • 2021-08-07
  • 2021-09-13
猜你喜欢
  • 2021-06-24
  • 2021-07-31
  • 2021-08-01
  • 2021-07-14
  • 2022-12-23
  • 2021-08-08
  • 2021-12-02
相关资源
相似解决方案