// Sat Nov 16 10:36:03 2024 // Problem "No.2963 Mecha DESU" in contest "unknown_contest" #include #include #include #pragma GCC optimize("O3") #include #ifdef NOJUDGE #define debug(...) fprintf(stderr, __VA_ARGS__) #else #define debug(...) #endif using namespace std; typedef long long int ll; const ll mod = 998244353; constexpr inline ll fastpow(ll x, ll p) { ll res = 1; while (p) { if (p & 1) res = res * x % mod; x = x * x % mod; p >>= 1; } return res; } constexpr inline ll inv(ll x) { return fastpow(x, mod - 2); } struct modint { ll x; double z; constexpr inline modint(ll x) : x(x % mod), z(x) {} constexpr inline modint(ll x, double z) : x(x % mod), z(z) {} constexpr inline modint operator+(modint y) { return modint(x + y.x, z + y.z); } constexpr inline modint operator-(modint y) { return modint(x - y.x, z - y.z); } constexpr inline modint operator*(modint y) { return modint(x * y.x, z * y.z); } constexpr inline modint operator/(modint y) { return modint(x * inv(y.x), z / y.z); } constexpr inline modint operator+=(modint y) { *this = *this + y; return *this; } constexpr inline modint operator-=(modint y) { *this = *this - y; return *this; } constexpr inline modint operator*=(modint y) { *this = *this * y; return *this; } constexpr inline modint operator/=(modint y) { *this = *this / y; return *this; } constexpr inline ll norm() { return (x + mod) % mod; } }; constexpr inline modint sqr(modint x) { return x * x; } constexpr inline modint fastpow(modint x, ll p) { return modint{fastpow(x.x, p), pow(x.z, p)}; } inline void solve() { ll n, m, k; scanf("%lld %lld %lld", &n, &m, &k); map freq; for (ll i = 0; i < m; i++) { ll x; scanf("%lld", &x); freq[x]++; } modint invm = modint{1} / modint(m); const ll N = n + 10; vector P(N, 0); for (auto [card, count] : freq) { for (ll i = card; i < N; i += card) { P[i] += modint{count} * invm; } } modint res{0}; for (ll i = 1; i <= n; i++) { debug("P[%lld] = %f\n", i, P[i].z); res += modint{1} - fastpow(modint{1} - P[i], k); } printf("%lld\n", res.norm()); debug("%f\n", res.z); } #define yukicoder int main() { #if defined(Codeforces) || defined(CodeChef) ll t; scanf("%lld", &t); for (int i = 0; i < t; i++) { solve(); } #else solve(); #endif }