#include #define int long long using namespace std; const int MOD = 998244353; // Function to calculate the modular inverse of 'a' modulo 'm' int modularInverse(int a, int m) { int m0 = m, t, q; int x0 = 0, x1 = 1; if (m == 1) return 0; // Apply extended Euclidean algorithm while (a > 1) { q = a / m; t = m; m = a % m, a = t; t = x0; x0 = x1 - q * x0; x1 = t; } // Make sure x1 is positive if (x1 < 0) x1 += m0; return x1; } // Function to calculate ((n * k) / k^n) % 998244353 int calculateExpression(int n, int k) { int numerator = (n * k) % MOD; int denominator = modularInverse(k, MOD); int exponent = n; // Calculate numerator * denominator^exponent modulo MOD int result = numerator; while (exponent > 0) { result = (result * denominator) % MOD; exponent--; } return result; } int32_t main() { int n, k; cout << "Enter the values of n and k: "; cin >> n >> k; int result = calculateExpression(n, k); cout << "Result: " << result << endl; return 0; }