Cod sursa(job #2026811)

Utilizator CodrinsahCotarlan Codrin Codrinsah Data 25 septembrie 2017 08:50:41
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <bitset>
#define lg 276997
using namespace std;
ifstream fi ("dtcsu.in");
ofstream fo ("dtcsu.out");
bitset<10000> hsh[3];
int i,h,x,q,sol;
int main()
{
    for (i=1;i<=lg;i++)
    {
      fi>>x;
      hsh[0][(5*x+(x%143)^2)%9973]=1;
      hsh[1][(8*x+(x%253)^2)%9967]=1;
      hsh[2][(3*x+(x%1003)^2)%9601]=1;
    }
    fi>>q;
    for (i=1;i<=q;i++)
    {
      fi>>x;
      bool ok=true;
      for (h=0;h<3;h++)
        if (hsh[h][x]==0) ok=false;
      if (ok) sol++;
    }
    fo<<sol;
    return 0;
}