Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- _____ _ _ _ _
- |_ _| |__ ___ / \ _ __ ___| |__ _ _| |
- | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
- | | | | | | __// ___ \| | | \__ \ | | | |_| | |
- |_| |_| |_|\___/_/ \_\_| |_|___/_| |_|\__,_|_|
- */
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ll long long
- #define pb push_back
- #define ppb pop_back
- #define endl '\n'
- #define mii map<ll,ll>
- #define msi map<string,ll>
- #define mis map<ll, string>
- #define rep(i,a,b) for(ll i=a;i<b;i++)
- #define repr(i,a,b) for(ll i=b-1;i>=a;i--)
- #define trav(a, x) for(auto& a : x)
- #define pii pair<ll,ll>
- #define vi vector<ll>
- #define vii vector<pair<ll, ll>>
- #define vs vector<string>
- #define all(a) (a).begin(),(a).end()
- #define F first
- #define S second
- #define sz(x) (ll)x.size()
- #define hell 1009
- #define lbnd lower_bound
- #define ubnd upper_bound
- #define max(a,b) (a>b?a:b)
- #define min(a,b) (a<b?a:b)
- /* For Debugging */
- #define DEBUG cerr<<"\n>>>I'm Here<<<\n"<<endl;
- #define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
- #define what_is(x) cerr << #x << " is " << x << endl;
- std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
- #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
- #define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
- #define DECIMAL(n) cout << fixed ; cout << setprecision(n);
- #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- using namespace __gnu_pbds;
- using namespace std;
- // #define PI 3.141592653589793
- #define N 200005
- using cd = complex<double>;
- const double PI = acos(-1);
- vi srss;
- // vi pw,pw1;
- ll expo(ll base, ll exponent, ll mod) { //return base^exponent modulo modulus
- ll ans = 1;
- while(exponent !=0 ) {
- if((exponent&1) == 1) {
- ans = ans*base ;
- ans = ans%mod;
- }
- base = base*base;
- base %= mod;
- exponent>>= 1;
- }
- return ans%mod;
- }
- void fft(vector<cd> & a, bool invert) {
- int n = a.size();
- for (int i = 1; i < n; i++) {
- if (i < srss[i])
- swap(a[i], a[srss[i]]);
- }
- for (int len = 2; len <= n; len <<= 1) {
- double ang = 2 * PI / len * (invert ? -1 : 1);
- cd wlen(cos(ang), sin(ang));
- for (int i = 0; i < n; i += len) {
- cd w(1);
- for (int j = 0; j < len / 2; j++) {
- cd u = a[i+j], v = a[i+j+len/2] * w;
- a[i+j] = u + v;
- a[i+j+len/2] = u - v;
- w *= wlen;
- }
- }
- }
- if (invert) {
- for (cd & x : a)
- x /= n;
- }
- }
- vector<int> multiply(vector<int> const& a, vector<int> const& b) {
- vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
- int n = 1;
- while (n < a.size() + b.size())
- n <<= 1;
- fa.resize(n);
- fb.resize(n);
- fft(fa, false);
- fft(fb, false);
- for (int i = 0; i < n; i++)
- fa[i] *= fb[i];
- fft(fa, true);
- vector<int> result(n);
- for (int i = 0; i < n; i++)
- result[i] = round(fa[i].real());
- return result;
- }
- void solve()
- {
- ll n,k,m;
- cin>>n>>m>>k;
- ll tmp=1;
- while(tmp<=n+m)
- tmp<<=1;
- srss.resize(tmp);
- for (int i = 1, j = 0; i < n; i++) {
- int bit = n >> 1;
- for (; j & bit; bit >>= 1)
- j ^= bit;
- j ^= bit;
- srss[i]=j;
- }
- vi v(m,0);;
- ll x;
- rep(i,0,n)
- {
- cin>>x;
- x--;
- v[x]++;
- }
- // pw.resize(tmp);
- // pw1.resize(tmp);
- // pw[0]=1;
- // rep(i,1,tmp)
- // {
- // pw[i]=(pw[i-1]*i)%hell;
- // }
- // rep(i,0,tmp)
- // {
- // pw1[i]=expo(pw[i],hell-2,hell);
- // }
- vector<cd> a[m];
- rep(i,0,m)
- {
- rep(j,0,v[i]+1)
- a[i].pb(cd(1));
- }
- rep(i,0,m)
- {
- a[i].resize(tmp);
- fft(a[i],false);
- }
- // rep(i,0,m)
- // {
- // rep(j,0,sz(a[i]))
- // cout<<a[i][j].real()<<" ";
- // cout<<endl;
- // }
- rep(i,0,tmp)
- {
- rep(j,1,m)
- a[0][i]*=a[j][i];
- }
- fft(a[0],true);
- rep(i,0,tmp)
- cout<<round(a[0][i].real())<<" ";
- cout<<endl;
- ll num=round(a[0][k].real());
- cout<<num<<endl;
- return;
- }
- int main()
- {
- FAST
- int TESTS=1;
- // cin>>TESTS;
- while(TESTS--)
- {
- solve();
- }
- TIME
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment