Submission #557873

#TimeUsernameProblemLanguageResultExecution timeMemory
557873FatihSolakW (RMI18_w)C++17
20 / 100
252 ms21236 KiB
#include <bits/stdc++.h> #define N 300005 using namespace std; const int mod = 1e9 + 7; long long fact[N]; long long ifact[N]; long long binpow(long long a,long long b){ long long ret = 1; while(b){ if(b & 1) ret = ret*a%mod; a = a*a%mod; b >>= 1; } return ret; } long long C(int n,int r){ return fact[n] * ifact[r]%mod*ifact[n-r]%mod; } void solve(){ int n; cin >> n; map<int,int> cnt; for(int i = 1;i<=n;i++){ int x; cin >> x; cnt[x]++; } vector<int> v; for(auto u:cnt) v.push_back(u.second); if(v[0] < 2 || v[1] < 3){ cout << 0; return; } cout << C(v[0]-2+1,1) *C(v[1]-3+2,2) %mod; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif fact[0] = ifact[0]= 1; for(int i = 1;i<N;i++){ fact[i] = fact[i-1] * i %mod; ifact[i] = binpow(fact[i],mod-2); } int t = 1; //cin >> t; while(t--){ solve(); } #ifdef Local cout << endl << fixed << setprecision(2) << 1000.0*clock()/CLOCKS_PER_SEC << " milliseconds."; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...