Pagini recente » Cod sursa (job #1580086) | Cod sursa (job #1626439) | Cod sursa (job #304186) | Cod sursa (job #2976992) | Cod sursa (job #2680648)
#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');
}
int lightread() {
while (!isdigit(buffer[++idx]));
int ans = buffer[idx] ^ '0';
while (isdigit(buffer[++idx]))
ans = (ans << 3) + (ans << 1) + (buffer[idx] ^ '0');
return ans;
}
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;
};