Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MOD 666013
- using namespace std;
- int n, A[11], T;
- long long a = 1, B;
- int factorial(int x)
- {
- if(x == 0) return 1 ;
- int sol = 1;
- for(int i = 2; i <= x; ++i)
- sol = (1LL * sol * i) % MOD;
- return sol;
- }
- int Invers_Modular(int x)
- {
- int sol = 1;
- int putere = MOD - 2;
- while(putere > 0)
- {
- if(putere & 1) sol = (1LL * sol * x) % MOD;
- x = (1LL * x * x) % MOD;
- putere >>= 1;
- }
- return sol;
- }
- int main()
- {
- freopen("mygo.in", "r", stdin);
- freopen("mygo.out", "w", stdout);
- for(int i = 0; i <= 9; ++i)
- {
- scanf("%d", &A[i]);
- T += A[i];
- }
- if(A[0] > 0)
- {
- a = factorial(T - 1);
- a = (1LL * a * Invers_Modular(factorial(A[0]))) % MOD;
- a = (1LL * a * Invers_Modular(factorial(T - 1 - A[0]))) % MOD;
- T -= A[0];
- }
- else a = 1;
- for(int i = 1; i <= 9; ++i)
- {
- if(A[i] > 0)
- {
- B = factorial(T);
- B = (1LL * B * Invers_Modular(factorial(A[i]))) % MOD;
- B = (1LL * B * Invers_Modular(factorial(T - A[i]))) % MOD;
- a = (a * B) % MOD;
- T -= A[i];
- }
- }
- printf("%lld", a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement