We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> ii; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ld> vd; typedef vector<ll> vl; typedef set<int> si; typedef set<ii> sii; typedef set<ld> sd; typedef set<ll> sl; typedef map<int, int> mii; typedef priority_queue<int> pqi; typedef queue<int> qi; #define mp make_pair #define pb push_back #define f first #define s second mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count()); template<typename T> T least_significant_one(T x) { return (x & (-x)); } struct fenwick_tree { int n; vl freq; fenwick_tree(int N) : n(N), freq(N + 1, 0) {}; ll sum(int a) { ll res = 0; for (; a; a -= least_significant_one(a)) res += freq[a]; return res; } void add(int a, int v) { for (; a <= n; a += least_significant_one(a)) freq[a] += v; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; vi a(n); for (auto &x : a) cin >> x; // compression si a_compress; for (auto &x : a) a_compress.insert(x); mii key, rkey; int ct = 1; for (auto &x : a_compress) { key[x] = ct; rkey[ct] = x; ct++; } fenwick_tree ct(a_compress.size() + 5), sum(a_compress.size() + 5); for (int i = 0; i < k - 1; i++) { ct.add(key[a[i]], 1); sum.add(key[a[i]], a[i]); } } /* USE LONG LONG!!!! :pray: :fishy15: :pray: :summitosity: :pray: :prodakcin: .= , =. _ _ /'/ )\,/,/(_ \ \ `//-.| ( ,\\)\//\)\/_ ) | //___\ `\\\/\\/\/\\///' / ,-"~`-._ `"--'_ `"""` _ \`'"~-,_ \ `-. '_`. .'_` \ ,-"~`/ `.__.-'`/ (-\ /-) |-.__,' || | \O) /^\ (O/ | . <- BESSIE THE COW `\\ | / `\ / \\ \ / `\ / `\\ `-. /' .---.--.\ `\\/`~(, '() (' /(O) \\ _,.-.,_) // \\ `\'` / / | || `""""~"` /' |__|| `o */
The text was updated successfully, but these errors were encountered:
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> ii; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ld> vd; typedef vector<ll> vl; typedef set<int> si; typedef set<ii> sii; typedef set<ld> sd; typedef set<ll> sl; typedef map<int, int> mii; typedef priority_queue<int> pqi; typedef queue<int> qi; #define mp make_pair #define pb push_back #define f first #define s second mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; vi a(n); for (auto &x : a) cin >> x; vector<mii> ct(10); for (auto x : a) { for (int i = 0; i < 10; i++, x *= 10) { x %= k; ct[i][x]++; } } int ans = 0; for (auto &x : a) { int l = log10(x); l++; ans += ct[l][n - x % k]; } cout << ans << endl; }
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: