|
| 1 | + |
| 2 | +//------------------------------------------------------------------------------ |
| 3 | +#include <iostream> |
| 4 | +#include <vector> |
| 5 | +// #include <bits/stdc++.h> |
| 6 | +// #include <cmath> |
| 7 | +// #include <algorithm> |
| 8 | +// #include <unordered_map> |
| 9 | +// #include <map> |
| 10 | +// #include <set> |
| 11 | +// #include <unordered_set> |
| 12 | +//------------------------------------------------------------------------------ |
| 13 | +using namespace std; |
| 14 | +//------------------------------------------------------------------------------ |
| 15 | +#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); |
| 16 | +#define v(Type) vector<Type> |
| 17 | +#define w(T) \ |
| 18 | + int T; \ |
| 19 | + cin >> T; \ |
| 20 | + while (T--) |
| 21 | +#define int long long int |
| 22 | +#define mod 1000000007ll |
| 23 | +#define endl "\n" |
| 24 | +//------------------------------------------------------------------------------ |
| 25 | +// Any fucntion can be called using Math.function_name(); |
| 26 | +//------------------------------------------------------------------------------ |
| 27 | +class Math |
| 28 | +{ |
| 29 | +public: |
| 30 | + //Returns gcd of two numbers |
| 31 | + int gcd(int a, int b) |
| 32 | + { |
| 33 | + return (a % b == 0) ? b : gcd(b, a % b); |
| 34 | + } |
| 35 | + |
| 36 | + //Returns lcm of two numbers |
| 37 | + int lcm(int a, int b) |
| 38 | + { |
| 39 | + return a * (b / gcd(a, b)); |
| 40 | + } |
| 41 | + |
| 42 | + // Returns flag array isPrime |
| 43 | + // isPrime[i] = true (if i is Prime) |
| 44 | + // isPrime[i] = false (if i is not Prime) |
| 45 | + vector<bool> *seiveOfEratosthenes(const int N) |
| 46 | + { |
| 47 | + vector<bool> *isPrime = new vector<bool>(N + 1, true); |
| 48 | + (*isPrime)[0] = (*isPrime)[1] = false; |
| 49 | + for (int i = 2; i * i <= N; ++i) |
| 50 | + if ((*isPrime)[i]) |
| 51 | + for (int j = i * i; j <= N; j += i) |
| 52 | + (*isPrime)[j] = false; |
| 53 | + |
| 54 | + return isPrime; |
| 55 | + } |
| 56 | + |
| 57 | + //Returns (x ^ n) |
| 58 | + int pow(const int &x, int n) |
| 59 | + { |
| 60 | + if (n == 0) |
| 61 | + return 1; |
| 62 | + int h = pow(x, n / 2); |
| 63 | + return (n & 1) ? h * h * x : h * h; |
| 64 | + } |
| 65 | + |
| 66 | + //Returns (x ^ n) % M |
| 67 | + int pow(const int &x, int n, const int &M) |
| 68 | + { |
| 69 | + if (n == 0) |
| 70 | + return 1; |
| 71 | + int h = pow(x, n / 2) % M; |
| 72 | + return (n & 1) ? (h * h * x) % M : (h * h) % M; |
| 73 | + } |
| 74 | + |
| 75 | + //Returns all Primes <= N |
| 76 | + vector<int> *primesUptoN(const int N) |
| 77 | + { |
| 78 | + vector<bool> *isPrime = seiveOfEratosthenes(N); |
| 79 | + vector<int> *Primes = new vector<int>; |
| 80 | + if (2 <= N) |
| 81 | + (*Primes).push_back(2); |
| 82 | + for (int i = 3; i <= N; i += 2) |
| 83 | + if ((*isPrime)[i]) |
| 84 | + (*Primes).push_back(i); |
| 85 | + return Primes; |
| 86 | + } |
| 87 | + |
| 88 | +} Math; |
| 89 | +//------------------------------------------------------------------------------ |
| 90 | +void solve() |
| 91 | +{ |
| 92 | + |
| 93 | +} |
| 94 | +//------------------------------------------------------------------------------ |
| 95 | +int32_t main() |
| 96 | +{ |
| 97 | + FastIO; |
| 98 | + |
| 99 | + // w(T) |
| 100 | + solve(); |
| 101 | + |
| 102 | + return 0; |
| 103 | +} |
| 104 | +//------------------------------------------------------------------------------ |
| 105 | + |
0 commit comments