답안 #557872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557872 2022-05-06T07:55:12 Z FatihSolak W (RMI18_w) C++17
0 / 100
277 ms 23192 KB
#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+3,3) *C(v[1]-3+3,3) %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
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 4948 KB Output isn't correct
2 Incorrect 44 ms 5004 KB Output isn't correct
3 Incorrect 51 ms 5336 KB Output isn't correct
4 Incorrect 73 ms 5816 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 4944 KB Output isn't correct
2 Incorrect 47 ms 4984 KB Output isn't correct
3 Incorrect 56 ms 6868 KB Output isn't correct
4 Incorrect 93 ms 11048 KB Output isn't correct
5 Incorrect 176 ms 16860 KB Output isn't correct
6 Incorrect 270 ms 23192 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 4940 KB Output isn't correct
2 Incorrect 50 ms 4892 KB Output isn't correct
3 Incorrect 49 ms 4924 KB Output isn't correct
4 Incorrect 45 ms 5000 KB Output isn't correct
5 Incorrect 45 ms 5020 KB Output isn't correct
6 Incorrect 46 ms 5244 KB Output isn't correct
7 Incorrect 46 ms 5312 KB Output isn't correct
8 Incorrect 58 ms 5580 KB Output isn't correct
9 Incorrect 71 ms 5928 KB Output isn't correct
10 Incorrect 277 ms 22812 KB Output isn't correct