Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Make CSP great again
- #include <bits/stdc++.h>
- #define TASK "TESTCODE"
- using namespace std;
- const int N = 1e6, mod = 1e9 + 7;
- long long cnt[N + 1];
- int n;
- int Pow(int a, long long b)
- {
- if (b == 0)
- {
- return 1;
- }
- int t = Pow(a, b/2);
- if (b % 2 == 0)
- {
- return (1LL * t * t) % mod;
- }
- else
- {
- return ((1LL * t * t) % mod * a) % mod;
- }
- }
- int Count(int i)
- {
- return (1LL * (Pow(i, cnt[i] + 1) - 1) * Pow(i - 1, mod - 2)) % mod;
- }
- void read()
- {
- cin >> n;
- for (int i = 1; i <= n; ++ i)
- {
- int x, k;
- cin >> x >> k;
- cnt[x] += k;
- }
- }
- void solve()
- {
- int res1 = 1, res2 = 1, res3 = 1, divcnt = 1;
- for (int i = 2; i <= N; ++ i)
- {
- res1 = (1LL * res1 * (cnt[i] + 1)) % mod;
- res2 = (1LL * res2 * Count(i)) % mod;
- res3 = (1LL * Pow(res3, cnt[i] + 1) * Pow(Pow(i, cnt[i] * (cnt[i] + 1)/2), divcnt) ) % mod;
- divcnt = (1LL * divcnt * (cnt[i] + 1)) % (mod - 1);
- }
- cout << res1 << ' ' << res2 << ' ' << res3;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- if (fopen(TASK".INP", "r"))
- {
- freopen(TASK".INP", "r", stdin);
- //freopen(TASK".OUT", "w", stdout);
- }
- int t = 1;
- bool typetest = false;
- if (typetest)
- {
- cin >> t;
- }
- for (int __ = 1; __ <= t; ++ __)
- {
- //cout << "Case " << __ <<": ";
- read();
- solve();
- }
- }
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement