救救孩子吧
查看原帖
救救孩子吧
352771
bajibaji_walawala楼主2020/10/27 18:56

改过之后的也不对
我输出呢??!!!被吃了?

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
long long int T,n,mod=500003;
long long int h[5078900],a;
int read();
bool push(long long int q)
{
	long long int s=abs(q%mod);
	while(h[s]!=-168430091)
	{
		if(h[s]==q) return true;
		else s++;
	}
	h[s]=q;
	return false;
}
int main(){
	T=read();
	while(T--)
	{
		memset(h,245,sizeof(h));
		n=read();
		while(n--)
		{
			a=read();
			if(push(a)==false) 
				printf("%lld ",a);	
		}
		printf("\n");
	}
	return 0;
}
int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

下面介个是最原来写的 emm 60

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cstring>
using namespace std;
long long int a,T,n,h[50050];
void push(long long int q,int i)
{
	for(int j=0;j<i;j++)
		if(h[j]==q)
			return;
	h[i]=q;
	return;
}
int main(){
	cin>>T;
	while(T!=0)
	{
		memset(h,-1,sizeof(h));
		T--;cin>>n;
		for(long long int i=0;i<n;i++)
		{
			cin>>a;
			push(a,i);	
		}
		for(int i=0;i<n;i++)
			if(h[i]!=-1) cout<<h[i]<<" ";
		cout<<endl;
	}
	return 0;
}

求救c⌒っ゚Д゚)っ

2020/10/27 18:56
加载中...