#include <cstdio> #include <vector> #include "dzilib.h" using namespace std; vector<int> primes; int dzielnikis[1000001]; int seqlen = 40; int main() { long long n = GetN(); long long c = GetC(); int t = GetT(); int q = GetQ(); dzielnikis[1] = 1; dzielnikis[2] = 2; dzielnikis[3] = 2; dzielnikis[4] = 3; dzielnikis[5] = 2; primes.push_back(2); primes.push_back(3); primes.push_back(5); for(int i = 6; i <= 1'000'000; ++i) { // if (i % 10000 == 0) { // printf("processing %d\n", i); // } int number = i; int result = 1; for(int j = 0; j < primes.size(); ++j) { int smallresult = 0; int prime = primes[j]; if (prime * prime > number) { if (number != 1) { // one prime left result *= 2; } break; } while (number % prime == 0) { number /= prime; smallresult++; } result *= (smallresult + 1); } if (result == 2) { primes.push_back(i); } dzielnikis[i] = result; } // for (int i = 1; i < 50; ++i) { // printf("%d: %d\n", i, dzielnikis[i]); // } if (n < 1'000'000'000LL) { for (int i = 0; i < t; ++i) { vector<int> askSequence; askSequence.reserve(seqlen); for (int j = 0; j < seqlen; ++j) { int dzielnik = int(Ask(j)); // printf("X + %d has %d dzielnikis\n", j, dzielnik); askSequence.push_back(dzielnik); } for(int j = 0; j < n; ++j) { // printf("TEST CASE %d: NUMBER %d\n", i, j); bool maybe = true; for (int k = 0; k < seqlen; ++k) { if (askSequence[k] != dzielnikis[j+k]) { // printf("BROKEN AT %d (%d vs %d)\n", j+k, askSequence[k], dzielnikis[j+k]); maybe = false; break; } } if (maybe) { // printf("GUESSING %d\n", j); Answer(j); break; } } } } else { // nie wiem } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <cstdio> #include <vector> #include "dzilib.h" using namespace std; vector<int> primes; int dzielnikis[1000001]; int seqlen = 40; int main() { long long n = GetN(); long long c = GetC(); int t = GetT(); int q = GetQ(); dzielnikis[1] = 1; dzielnikis[2] = 2; dzielnikis[3] = 2; dzielnikis[4] = 3; dzielnikis[5] = 2; primes.push_back(2); primes.push_back(3); primes.push_back(5); for(int i = 6; i <= 1'000'000; ++i) { // if (i % 10000 == 0) { // printf("processing %d\n", i); // } int number = i; int result = 1; for(int j = 0; j < primes.size(); ++j) { int smallresult = 0; int prime = primes[j]; if (prime * prime > number) { if (number != 1) { // one prime left result *= 2; } break; } while (number % prime == 0) { number /= prime; smallresult++; } result *= (smallresult + 1); } if (result == 2) { primes.push_back(i); } dzielnikis[i] = result; } // for (int i = 1; i < 50; ++i) { // printf("%d: %d\n", i, dzielnikis[i]); // } if (n < 1'000'000'000LL) { for (int i = 0; i < t; ++i) { vector<int> askSequence; askSequence.reserve(seqlen); for (int j = 0; j < seqlen; ++j) { int dzielnik = int(Ask(j)); // printf("X + %d has %d dzielnikis\n", j, dzielnik); askSequence.push_back(dzielnik); } for(int j = 0; j < n; ++j) { // printf("TEST CASE %d: NUMBER %d\n", i, j); bool maybe = true; for (int k = 0; k < seqlen; ++k) { if (askSequence[k] != dzielnikis[j+k]) { // printf("BROKEN AT %d (%d vs %d)\n", j+k, askSequence[k], dzielnikis[j+k]); maybe = false; break; } } if (maybe) { // printf("GUESSING %d\n", j); Answer(j); break; } } } } else { // nie wiem } return 0; } |