Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define prm(x) x.begin(), x.end()
- #define srt(x) sort(prm(x))
- #define rvs(x) reverse(prm(x))
- using namespace std;
- using ll = long long;
- using ld = long double;
- int main()
- {
- // ifstream cin("eq4.in");
- // ofstream cout("eq4.out");
- ll c;
- cin >> c;
- cin.ignore();
- string x;
- getline(cin, x);
- ll l, r, v;
- cin >> l >> r >> v;
- map<char, ll> z1;
- for (int i = 0; i < x.size();)
- {
- ll a, b = 0;
- char ct = 'w';
- if (x.at(i) == '+')
- {
- a = 1;
- }
- else
- {
- a = -1;
- }
- i++;
- while (i < x.size() && isdigit(x.at(i)))
- {
- b = b * 10 + (x.at(i) - '0');
- i++;
- }
- if (i < x.size() && isalpha(x.at(i)))
- {
- ct = x.at(i);
- i++;
- }
- if (b == 0)
- {
- b = 1;
- }
- z1[ct] += a * b;
- }
- if (c == 1)
- {
- cout << z1['x'] + z1['y'] + z1['z'] + z1['t'] + z1['w'] << endl;
- }
- else
- {
- ll ans = 0;
- ll hp = z1['w'];
- map<ll, ll> v1;
- for (int i = l; i < r; i++)
- {
- for (int j = l; j < r; j++)
- {
- v1[hp + z1['x'] * i + z1['y'] * j] += 1;
- }
- }
- for (int i = l; i < r; i++)
- {
- for (int j = l; j < r; j++)
- {
- ll val = v - (z1['z'] * i + z1['t'] * j);
- if (v1.find(val) != v1.end())
- {
- ans += v1[val];
- }
- }
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement