Pagini recente » Cod sursa (job #547979) | Cod sursa (job #194044) | Cod sursa (job #1511596) | Cod sursa (job #332374) | Cod sursa (job #2681046)
#include <chrono>
#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
//#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <ext/pb_ds/assoc_container.hpp>
struct marijuana {
static unsigned long long splitmix64(unsigned long long x) { //incearca ull
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(unsigned long long x) const {
static const unsigned long long FIXED_RANDOM = std::chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
}; __gnu_pbds::gp_hash_table <unsigned long long, char, marijuana> hash;
/* struct stat sb;
char *buffer;
void init() {
int fd = open("dtcsu.in", O_RDONLY);
fstat(fd, &sb);
buffer = (char*)mmap(0, sb.st_size, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, fd, 0);
close(fd);
}
int idx = -1;
inline void read(unsigned long long *n) {
while (!isdigit(buffer[++idx]));
*n = buffer[idx] ^ '0';
while (isdigit(buffer[++idx]))
*n = (*n << 3ull) + (*n << 1ull) + (buffer[idx] ^ '0');
} */
#define BUFSIZE 0x20000
int rpos;
char rbuf[BUFSIZE], cf[9];
FILE *fin = fopen("dtcsu.in", "w");
static inline char readChar() {
if (!(rpos = (rpos+1) & (BUFSIZE-1)))
fread(rbuf, 1, BUFSIZE, fin);
return rbuf[rpos];
}
inline void read(unsigned long long *n) {
int ch;
while (!isdigit(ch = readChar()));
*n = ch ^ '0';
while (isdigit(ch = readChar()))
*n = (*n << 3ull) + (*n << 1ull) + (ch ^ '0');
}
int lightread() {
int ch, ret = 0;
while (!isdigit(ch = readChar()));
do
ret = (ret << 3) + (ret << 1) + (ch ^ '0');
while (isdigit(ch = readChar()));
return ret;
}
int main(void) {
unsigned long long n;
//init();
int sex = 2276997;
for (; sex; --sex) {
read(&n);
if (n & 1ull)
hash[n] = 1;
}
int ans = 0;
for (sex = lightread(); sex; --sex) {
read(&n);
if (hash[n >> __builtin_ctzll(n)])
++ans;
}
fprintf(fopen("dtcsu.out", "w"), "%d", ans);
return 0;
};