diff --git a/Problem Statement-1/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-1.cpp b/Problem Statement-1/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-1.cpp new file mode 100644 index 0000000..ceda83c --- /dev/null +++ b/Problem Statement-1/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-1.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +void solve() +{ + long long int n, a, b, k; + cin >> n >> a >> b >> k; + long long int ans = 0; + + long long int x = a * b; + for (long long int i = 1; i <= n; ++i) + { + if (i % x == 0) + continue; + if (i % a == 0 || i % b == 0) + ans++; + } + + if (ans >= k) + cout << "Win" << endl; + else + cout << "Lose" << endl; +} + +int main() +{ + int t; + cin >> t; + + while (t--) + solve(); + + return 0; +} diff --git a/Problem Statement-2/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-2.cpp b/Problem Statement-2/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-2.cpp new file mode 100644 index 0000000..7dbf959 --- /dev/null +++ b/Problem Statement-2/Solution/TechSpiritSS/TechSpiritSS_gameofcodes_Ps-2.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +int main() +{ + int n, size; + cin >> n; + string s; + cin >> s; + size = n; + + int arr[26] = {0}; + + for (int i = 0; i < n; ++i) + arr[s[i] - 'a']++; + + while (n % 2 == 0) + { + for (int i = 0; i < 26; ++i) + { + if (arr[i] == 1) + continue; + arr[i] /= 2; + } + n /= 2; + } + + int count = 0; + string x = ""; + + for (int i = 0; i < 26; ++i) + { + if (arr[i] == 0) + continue; + count += arr[i]; + while (arr[i]--) + x += (char)(i + 'a'); + } + + cout << size / (count * 2) << endl + << x << endl; +}