P1866 为啥不用if判断不可能情况也能过
  • 板块P1866 编号
  • 楼主lmycube
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/5/22 12:14
  • 上次更新2023/10/28 00:52:41
查看原帖
P1866 为啥不用if判断不可能情况也能过
625560
lmycube楼主2022/5/22 12:14

代码20行的判断为啥注释了也AC了

(看最优解也没判断,就试了一下结果过了。。

#include <bits/stdc++.h>
using namespace std;
int maxn[55];
#define INF 1000000007
typedef unsigned long long ull;
int main()
{
    ios::sync_with_stdio(0);
    int n,i;
    ull ans=1;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>maxn[i];
    }
    sort(maxn,maxn+n);
    for(i=0;i<n;i++){
        /*
        if(maxn[i]<i){
            cout<<0<<endl;
            return 0;
        }
        else {
            */
            ans*=(maxn[i]-i);
            ans%=INF;
        
    }
    cout<<ans<<endl;
}
2022/5/22 12:14
加载中...