牛客多校第一场 H之hack

牛客第一场的H题
这是一份ac代码
```
//#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define ll long long
//#define inf 0x3f3f3f3f
//#define Inf 0x3f3f3f3f3f3f3f3f
using namespace std;
const int mod = 1e9+7;
const int MAX = 5e5+5;
int a[MAX];
bool book[MAX];
int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(false);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",a+i);
        book[a[i]]=1;
    }
    sort(a+1,a+n+1);
    int ans=n;
    while(ans<=a[n])
    {
        int flag=1;
        for(int i=n;a[i]>=ans;--i){
            if(book[a[i]%ans]){
                flag=0;break;
            }
        }
        if(flag)break;
        ans++;
    }

    printf("%d\n",ans);

    return 0;
}

```
但是我们对样例 
3
7 10 2
进行自测 发现自测结果是3 ,很显然这是一个错误答案,但是该程序却能ac
很显然第一场多校的H 数据大水了
全部评论
的确水了,我们用暴力过了
1 回复
分享
发布于 2021-07-17 19:01
根本不知道啥是hash的蒟蒻路过😅
点赞 回复
分享
发布于 2021-07-18 01:15
滴滴
校招火热招聘中
官网直投

相关推荐

27 收藏 评论
分享
牛客网
牛客企业服务