#include // #include #include #include using namespace std; using namespace __gnu_pbds; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; // https://docs.google.com/document/d/1VuLkJfkaBBFdcV-BPtT2JdTDrD2lC3POFj6NPTl_Pzo/edit?addon_store&tab=t.0 typedef tree, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key //find by order-> element at ith idx(starting from 0)//gives iterator to that index//if not present *it gives 0 //order of key-> number of element less than a number // erase function for ordered multiset // void myerase(pbds &t, int v){ // int rank = t.order_of_key(v);//Number of elements that are less than v in t // pbds::iterator it = t.find_by_order(rank); //Iterator that points to the (rank+1)th element in t // t.erase(it); // } #define int long long int // #define ll long long int #define loop(var, s, e) for(int var = s; var < e; var++) #define rloop(var, e, s) for(int var = e; var>= s; var--) #define v vector // #define vll vector #define printyes cout<<"YES\n" #define printno cout<<"NO\n" //COMMENT THIS FOR INTERACTIVE PROBLEMS............... // #define endl '\n' #define mod (int)(998244353) #define inf 1e18 #define dbg(x) cerr<<"value of "<<#x<<" is => "<> #define pii pair #define pll pair #define ff first #define ss second #define pb push_back #define eb emplace_back #define vpll vector #define here(i) cerr<<"here "< ostream& operator<<(ostream& out, const vector& ve); template ostream& operator<<(ostream& out, const pair& a); template ostream& operator<<(ostream& out, const pair& a) { return out << "(" << a.first << ", " << a.second << ")"; } template ostream& operator<<(ostream& out, const vector& ve) { out << "["; loop(i, 0, ve.size()) { if (i) out << ", "; out << ve[i]; } return out << "]"; } namespace bit { int setBit(int n, int bitNo) { n = (n|(1LL< 1000-> 3 n&(n - 1) clears the first set bit n&(-n) give the first set bit => 101100 -> 000100 n&(n + 1) clear all trailing ones n|(n + 1) set the first unset bit */ } //*************************************************CHECK THE CONSTRAINTS**********************************************************// int extendedEuclidean(int a, int b, int&x, int& y) { if(b == 0) { x = 1; y = 0; return a; } int x1, y1; int d = extendedEuclidean(b, a%b, x1, y1); x = y1; y = x1 - y1*(a/b); return d; } int f(int a, int b) { if(b == 0)return 1; int res = f(a, b/2); if(b%2 != 0) { return (((res)%mod* (res)%mod)%mod * a)%mod; } else { return ((res)%mod * (res)%mod)%mod; } } int _f(int a, int b) { if(b == 0)return 1; int res = f(a, b/2); if(b%2 != 0) { return (((res)* (res))* a); } else { return ((res) * (res)); } } int inv(int a, int b){ return 1 linear_sieve(int n) { //https://cp-algorithms.com/algebra/prime-sieve-linear.html vector lp(n + 1, 0); vector primes; loop(i, 2, n + 1) { if(lp[i] == 0) { primes.pb(i); lp[i] = i; } for(int j = 0; i * primes[j] <= n; j++) { lp[primes[j] * i] = primes[j]; if(primes[j] == lp[i])break; } } return pair{lp, primes}; } vector sieve(int n) { vector is_prime(n+1, 1); // v prime; // v dp(n + 1, 0); is_prime[0] = 0; is_prime[1] = 0; for(int i = 2; i <= n; i++) { if(is_prime[i] == 1) { // prime.pb(i); for(int j = i*i; j <= n; j+=i) { is_prime[j] = 0; } } } return is_prime; } int floor_div(int a, int b) { int res = a/b; if(a > 0 && b < 0 || a < 0 && b > 0)res--; return res; } int ceil_div(int a, int b) { if(a > 0 && b < 0 || a < 0 && b > 0) { return a/b; } return (a + b - 1)/b; } // void *memcpy(void *dest, const void *src, size_t n); // make the hard time of your life as your strength // first write complete pseudo code on paper then code dont care about the time!!!!!! const int delRow[16] = {1, 0, 0, -1, 1, 1, -1, -1, 2, 2, 1, 1, -1, -1, -2, -2}; const int delCol[16] = {0, -1, 1, 0, -1, 1, -1, 1, -1, 1, -2, 2, -2, 2, -1, 1}; // U L D R //find by order-> element at ith idx(starting from 0)//gives iterator to that index//if not present *it gives 0 //order of key-> number of element less than a number void pikachu(int tt, int tc) { int n, k; cin>>n>>k; v arr(n); loop(i, 0, n)cin>>arr[i]; int sub = 1; int big = 1; loop(i, 0, n) { if(arr[i] >= k) { int a = inv(arr[i], mod); int b = (a * (k - 1))%mod; sub = (sub * b)%mod; big = (big * ((a + b)%mod))%mod; } } cout<<(big - sub + mod)%mod<>gsBall; int tt = gsBall; int tc = 1; cout<(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }