Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int, int>
- #define pb(x) push_back(x)
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvl(vector <ll> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvv(vector <vector <int> > &v) {
- for (auto x : v) cv(x);
- cout << "\n";
- }
- void cvb(vector <bool> v) {
- for (bool x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvs(vector <string> v) {
- for (auto a : v) {
- cout << a << "\n";
- }
- }
- void cvp(vector <pii> a) {
- for (auto p : a) {
- cout << p.first << ' ' << p.second << "\n";
- }
- cout << "\n";
- }
- int main() {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- int n;
- cin >> n;
- bool sh = 0;
- vector <int> v(n);
- int til = 500;
- vector <ll> dp(600, 0);
- for (int &i: v) {
- cin >> i;
- dp[i]++;
- }
- ll ans = 0;
- vector <ll> pf(520, 0);
- for (ll i = 1; i <= til; ++i) {
- pf[i] = pf[i - 1] + dp[i];
- }
- if (sh) {
- cout << "pf\n";
- cvl(pf);
- }
- //pf - именно кол-вотаких-то чисел, а не сумма
- for (int a = 1; a <= til; ++a) {
- for (int b = 1; b <= til; ++b) {
- for (int c = 1; c <= til; ++c) {
- if (dp[a] == 0 || dp[b] == 0 || dp[c] == 0) {
- continue;
- }
- ll fro = a * b / c;
- if (fro * c < a * b) fro++;
- if (fro > 500) {
- continue;
- }
- ll del = 0;
- if (fro - 1 >= 0) {
- del = pf[fro - 1];
- }
- ll Sd = pf[til] - del;
- ll plu = dp[a] * dp[b] * dp[c] * Sd;
- ans += plu;
- if (sh && plu > 0 && fro == 18) {
- cout << "a b c = " << a << ' ' << b << ' ' << c << "\n";
- cout << "fro = " << fro << "\n";
- cout << "Sd = " << Sd << "\n";
- cout << "plu = " << plu << "\n";
- cout << "del = " << del << "\n";
- cout << "\n\n";
- }
- }
- }
- }
- cout << ans;
- }
- /*
- a b c = 6 6 2
- fro = 18
- Sd = 3
- plu = 3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement