Submission #1174767

#TimeUsernameProblemLanguageResultExecution timeMemory
1174767nuutsnoyntonZoltan (COCI16_zoltan)C++20
14 / 140
81 ms9800 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; ll fac[1000006]; ll Pow(ll a, ll b) { if ( b == 0) return 1; if ( b == 1) return a % mod; ll r = Pow(a, b/2); r = r * r %mod; if ( b % 2 == 1) r= r * a %mod; return r; } int main() { ll n, m, r, x, y, i, j, ans, t, s, cnt; fac[0]= 1; for (i = 1; i<= 1e6; i ++) { fac[i] = (fac[i - 1] * i ) % mod; } cin >> n; ll a[n +2]; for (i = 1; i <= n; i ++) { cin >> a[i]; } cnt = 1; r = 1; while ( r <= n && a[r] == a[1]) r ++; r --; ans = Pow(2, r - 1); sort ( a + 1, a +n + 1); for (i = 1; i <= n; i++) { cnt ++; r = i; while (r <= n && a[r] == a[i]) { r ++; } ans = ans * fac[r - i ]; ans %= mod; i = r - 1; } cout << cnt - 1<< " " << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...