hdu1425最简单hash(加速输入外挂。。)

各种找各类水题做啊。。。

不多说了,最简单哈希。

然后发现了一个外挂哈哈。。。。

代码:

#include<iostream>
#include<cstdio>
#include<memory.h>
#include<cstring>
using namespace std;
#define N 1000001
bool hash[N];
inline bool scan_d(int &num)  //加速输入外挂!!!
{
    char in;
    bool IsN = false;

    in = getchar();
    if(in == EOF) return false;

    while(in!='-' && (in<'0'||in>'9')) in = getchar();

    if(in == '-') {IsN = true; num = 0;}
    else num = in-'0';

    while(in = getchar(), in>='0'&&in<='9')
    {
        num *= 10, num += in-'0';
    }
    if(IsN) num = -num;
    return true;
}
int main()
{
    int n,m,x,k;
    while(cin>>n>>m)
    {
        memset(hash,false,sizeof(hash));
        for(int i=0;i<n;i++)
        {
            scan_d(x);
            hash[x+500000]=true;
        }
        k=0;
        for(int i=N-1;k!=m;i--)
        {
            if(hash[i])
            {
                k++;
                if(k!=1)
                cout<<" ";
                cout<<i-500000;
            }
        }
        cout<<endl;

    }
    return 0;
}


 

原文地址:https://www.cnblogs.com/amourjun/p/5134185.html