Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- using namespace std;
- const int N = 2e5;
- int n, k;
- long long a[N+1], cnt = 0, b[65];
- void read()
- {
- cin >> n >> k;
- fill (b + 1, b + 65, 0);
- for (int i = 1; i <= n; ++ i)
- {
- cin >> a[i];
- int cnt = 0;
- while (a[i] % 2 == 0)
- {
- ++cnt;
- a[i]/=2;
- }
- a[i] = cnt;
- ++b[cnt];
- }
- }
- long long c3(long long x)
- {
- return x*(x-1)*(x-2)/6;
- }
- long long c2 (long long x)
- {
- return x*(x-1)/2;
- }
- void solve()
- {
- for (int i = 0; i <= 64; ++ i)
- {
- for (int j = i + 1; j <= 64; ++ j)
- {
- for (int z = j + 1; z <= 64; ++ z)
- {
- if (i + j + z >= k)
- {
- cnt += b[i] * b[j] * b[z];
- }
- }
- }
- }
- for (int i = 0; i <= 64; ++ i)
- {
- for (int j = i + 1; j <= 64; ++ j)
- {
- if (2 * i + j >= k)
- {
- cnt += c2(b[i]) * b[j];
- }
- if (i + 2 * j >= k)
- {
- cnt += b[i] * c2(b[j]);
- }
- }
- }
- for (int i = 0; i <= 64; ++ i)
- {
- if (3 * i >= k)
- {
- cnt += c3(b[i]);
- }
- }
- cout << cnt;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- read();
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement