diff --git a/October 2024/Codechef Contest Problems/a.exe b/October 2024/Codechef Contest Problems/a.exe new file mode 100644 index 00000000..796ddfce Binary files /dev/null and b/October 2024/Codechef Contest Problems/a.exe differ diff --git a/October 2024/Codechef Contest Problems/chefAndParole.c++ b/October 2024/Codechef Contest Problems/chefAndParole.c++ new file mode 100644 index 00000000..b5037128 --- /dev/null +++ b/October 2024/Codechef Contest Problems/chefAndParole.c++ @@ -0,0 +1,19 @@ +#include +using namespace std; + +int main() +{ + int X; + cin >> X; + + if (X >= 7) + { + cout << "Yes" << endl; + } + else + { + cout << "No" << endl; + } + + return 0; +} \ No newline at end of file diff --git a/October 2024/Codechef Contest Problems/gcd.c++ b/October 2024/Codechef Contest Problems/gcd.c++ new file mode 100644 index 00000000..f52c12b6 --- /dev/null +++ b/October 2024/Codechef Contest Problems/gcd.c++ @@ -0,0 +1,82 @@ +#include +using namespace std; + +bool isPrime(int n) +{ + // Since 0 and 1 is not prime + // return false. + if (n == 1 || n == 0) + return false; + + // Run a loop from 2 to + // square root of n. + for (int i = 2; i * i <= n; i++) + { + // If the number is divisible by i, + // then n is not a prime number. + if (n % i == 0) + return false; + } + + // Otherwise n is a prime number. + return true; +} + +vector firstnp(int n) +{ + int limit = max(15, static_cast(n * log(n) + n * log(log(n)))); + vector isp(limit + 1, true); + isp[0] = isp[1] = false; + for (int p = 2; p * p <= limit; p++) + { + if (isp[p]) + { + for (int m = p * p; m <= limit; m += p) + { + isp[m] = false; + } + } + } + + vector primes; + for (int p = 2; primes.size() < n && p <= limit; p++) + { + if (isp[p]) + primes.push_back(p); + } + return primes; +} + +int main() +{ + int t; + cin >> t; + while (t--) + { + int n, m; + cin >> n >> m; + int a[n][m]; + vector v = firstnp(m * n); + int count = 0; + // sieve_of_eratosthenes(v); + + count = 0; + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { + a[i][j] = v[count]; + count++; + } + } + + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { + cout << a[i][j] << " "; + } + cout << endl; + } + } +} \ No newline at end of file diff --git a/October 2024/Codechef Contest Problems/rectangled.c++ b/October 2024/Codechef Contest Problems/rectangled.c++ new file mode 100644 index 00000000..da01e85c --- /dev/null +++ b/October 2024/Codechef Contest Problems/rectangled.c++ @@ -0,0 +1,28 @@ +#include +using namespace std; + +int main() +{ + // your code goes here + int T; + cin >> T; + while (T > 0) + { + T--; + int n; + int l = 0, b = 0; + cin >> n; + for (int i = 1; i < n; i++) + { + for (int j = 1; j < n; j++) + { + if ((i * j > l * b) && 2 * (i + j) <= n) + { + l = i; + b = j; + } + } + } + cout << l * b << endl; + } +} \ No newline at end of file