Pagini recente » Cod sursa (job #2255795) | Cod sursa (job #2913251) | Cod sursa (job #2036023) | Cod sursa (job #2396180) | Cod sursa (job #1259511)
#include <cstdio>
#include <vector>
#define MOD 666013
using namespace std;
int n,m,a,b,c,d,e,i,ind,x,SOL,X,Y,VAL;
vector <int> h[MOD+10];
vector <int>::iterator it;
vector <int>::iterator find(int x)
{
for (it=h[ind].begin();it!=h[ind].end();it++) if (*it==x) return it;
return it;
}
void insert(int x)
{
if (it==h[ind].end()) h[ind].push_back(x);
}
int main()
{
freopen("muzica.in","r",stdin);
freopen("muzica.out","w",stdout);
scanf("%d %d", &n, &m);
scanf("%d %d %d %d %d", &a, &b, &c ,&d, &e);
for (i=1;i<=n;++i)
{
scanf("%d", &x);
ind=x%MOD;
it=find(x);
insert(x);
}
m-=2;
ind=a%MOD;
it=find(a);
if (it!=h[ind].end())
{
SOL++;
h[ind].erase(it);
}
ind=b%MOD;
it=find(b);
if (it!=h[ind].end())
{
SOL++;
h[ind].erase(it);
}
X=a; Y=b;
for (;m;--m)
{
VAL=(c*X+d*Y)%e;
ind=VAL%MOD;
it=find(VAL);
if (it!=h[ind].end())
{
SOL++;
h[ind].erase(it);
}
X=Y; Y=VAL;
}
printf("%d\n", SOL);
return 0;
}