Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************|
- | Basic ass template for basic ass problems |
- | - Mohd Safwan |
- | https://safwankdb.github.io |
- |__________________________________________*/
- #pragma GCC optimize ("O3")
- #pragma GCC target ("avx2")
- #include <bits/stdc++.h>
- using namespace std;
- #define REP(i, s, e) for (int i = (s); i < (e); i++)
- #define REPR(i, e, s) for (int i = (e) - 1; i >= (s); i--)
- #define SPEED ios_base::sync_with_stdio(0); cin.tie(0);
- #define endl '\n'
- typedef long long ll;
- typedef unsigned long long ull;
- typedef array<ll, 2> ii;
- template <typename T>
- using V = vector<T>;
- const int MOD = 1e9 + 7;
- const int INF = 1e7 + 5;
- const int LOG = 32;
- typedef array<array<ll, 9>, 9> Mat;
- Mat operator*(Mat &a, Mat &b) {
- Mat ans = {};
- REP(i, 0, 9) REP(k, 0, 9) REP(j, 0, 9) {
- ans[i][j] += a[i][k] * b[k][j];
- }
- return ans;
- }
- Mat Pow(Mat &a, int n) {
- Mat ans = {};
- REP(i, 0, 9) ans[i][i] = 1;
- while (n) {
- if (n & 1) ans = ans * a;
- a = a * a;
- n /= 2;
- }
- return ans;
- }
- int main() {
- SPEED
- int n = 300;
- V<ull> F(9, 0);
- REP(i, 0, n) {
- int t;
- cin >> t;
- F[t]++;
- }
- Mat M = {};
- REP(i, 0, 8) M[i][i+1] = 1;
- M[6][0] = 1;
- M[8][0] = 1;
- M = Pow(M, 256);
- ull ans = 0;
- REP(i, 0, 9) REP(j, 0, 9) ans += M[i][j] * F[j];
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement