Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #define task "xorseq"
- using namespace std;
- using ll = long long;
- using ld = long double;
- const int N = 1e2 + 5;
- int n;
- ll k;
- ll a[N];
- const ll mod = 998244353;
- struct Matrix
- {
- ll a[N][N];
- Matrix()
- {
- memset(a, 0, sizeof a);
- }
- Matrix operator*(const Matrix &x)
- {
- Matrix ans;
- for (int i = 1; i <= n; ++i)
- for (int j = 1; j <= n; ++j)
- for (int k = 1; k <= n; ++k)
- (ans.a[i][j] += a[i][k] * x.a[k][j]) %= mod;
- return ans;
- }
- } base, v;
- Matrix Pow(Matrix &a, ll k)
- {
- Matrix ans;
- for (int i = 1; i <= n; ++i)
- ans.a[i][i] = 1;
- for (; k > 0; k >>= 1)
- {
- if (k & 1)
- ans = ans * a;
- a = a * a;
- }
- return ans;
- }
- void Read()
- {
- cin >> n >> n >> k;
- for (int i = 1; i <= n; ++i)
- {
- cin >> a[i];
- for (int j = 1; j <= n; ++j)
- if (__builtin_popcountll(a[i] ^ a[j]) % 3 == 0)
- v.a[i][j] = v.a[j][i] = 1;
- }
- if (k == 1)
- {
- cout << n;
- exit(0);
- }
- }
- void Solve()
- {
- v = Pow(v, k - 1);
- for (int i = 1; i <= n; ++i)
- base.a[i][1] = 1;
- v = v * base;
- ll ans = 0;
- for (int i = 1; i <= n; ++i)
- (ans += v.a[i][1]) %= mod;
- cout << ans;
- }
- int32_t main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement