This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <any> | |
| #include <print> | |
| #include <string> | |
| using namespace std; | |
| #pragma GCC diagnostic ignored "-Wnon-template-friend" | |
| template<class... Ts> | |
| class A { | |
| public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I'm changing `auto x` and `auto y` to `auto a` and `auto b` because `x` shows up in a lot of places and isn't the same name: https://godbolt.org/z/9x5dvcofY | |
| Lines 27 and 28: | |
| auto a = AffineType{}; | |
| auto b = AffineType{}; | |
| Because AffineType is templated on `InstanceIdentifier` but a template argument isn't provided, the compiler must deduce what it is templated on. There is a default value, which is a lambda. Each lambda is a *unique value*, so the type of `a` and `b` is different - `a = b;` would also be a compiler error. I will be calling those lambda values `LV1` and `LV2`, and so those lines are actually: | |
| 27: AffineType<LV1> a{}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <any> | |
| #include <print> | |
| #include <string> | |
| #include<bits/stdc++.h> | |
| using namespace std; | |
| struct poly_base { | |
| virtual void operator()(std::vector<std::any> args) = 0; | |
| virtual ~poly_base()=default; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <any> | |
| #include <print> | |
| #include <string> | |
| #include <type_traits> | |
| using namespace std; | |
| #pragma GCC diagnostic ignored "-Wnon-template-friend" | |
| template <class T, class... Ts> | |
| class A : A<Ts...> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| #include <cassert> | |
| using namespace std; | |
| string s = | |
| "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n\ | |
| 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\n\ | |
| 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65\n\ | |
| 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91\n\ | |
| 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80\n\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| #include <cassert> | |
| using namespace std; | |
| int main() { | |
| int n = 2e6; | |
| long long sum = 2; | |
| for (int i = 3; i < n; i += 2) { | |
| bool prime = true; | |
| for (int j = 2; j * j <= i; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| // find two numbers who's squares, when added, equal a number whose square root, plus those two numbers equals 1000 | |
| int main() { | |
| cout << []{ | |
| int n = 1000; | |
| for (int a = 1; a <= n; a++) { | |
| for (int b = a + 1; b <= n; b++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| string num = "73167176531330624919225119674426574742355349194934\ | |
| 96983520312774506326239578318016984801869478851843\ | |
| 85861560789112949495459501737958331952853208805511\ | |
| 12540698747158523863050715693290963295227443043557\ | |
| 66896648950445244523161731856403098711121722383113\ | |
| 62229893423380308135336276614282806444486645238749\ | |
| 30358907296290491560440772390713810515859307960866\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| #include <cassert> | |
| using namespace std; | |
| int main() { | |
| int n = 10001; | |
| int limit = n/2; | |
| vector<int> prime; | |
| while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| #include <cassert> | |
| using namespace std; | |
| int main() { | |
| int n = 100; | |
| int result = (n * (n + 1) * (3 * n * (n + 1) - 2 * (2 * n + 1)))/12; | |
| cout << result; | |
| } |
NewerOlder