답안 #557871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557871 2022-05-06T07:54:32 Z FatihSolak W (RMI18_w) C++17
컴파일 오류
0 ms 0 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;
		mp[x]++;
	}
	vector<int> v;
	for(auto u:mp)
		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[i]= 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
}

Compilation message

w.cpp: In function 'void solve()':
w.cpp:27:3: error: 'mp' was not declared in this scope
   27 |   mp[x]++;
      |   ^~
w.cpp:30:13: error: 'mp' was not declared in this scope
   30 |  for(auto u:mp)
      |             ^~
w.cpp: In function 'int main()':
w.cpp:45:18: error: 'i' was not declared in this scope
   45 |  fact[0] = ifact[i]= 1;
      |                  ^