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

来源:互联网 发布:阿里云最便宜多少钱 编辑:程序博客网 时间:2024/06/06 09:00

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

不多说了,最简单哈希。

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

代码:

#include<iostream>#include<cstdio>#include<memory.h>#include<cstring>using namespace std;#define N 1000001bool 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;}


 

原创粉丝点击