Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #include <vector>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- int main1() {
- int n = 0;
- cin >> n;
- int i = 2;
- while (i <= sqrt(n) + 1) {
- while (n % i == 0) {
- n /= i;
- cout << i << " ";
- }
- ++i;
- }
- if (n != 1) cout << n;
- return 0;
- }
- int main2() {
- ull a = 0;
- cin >> a;
- int n = 0;
- cin >> n;
- ull result = 1ull;
- for (int i = 0; i < n; ++i) {
- result = (result * a) % 1000000007;
- }
- cout << result << endl;
- double integral_part = 0;
- double result2 = modf(pow(double(a), double(n)) / 1000000007., &integral_part);
- result2 *= 1000000007.;
- cout << ull(result2) << endl;
- return 0;
- }
- int main() {
- int n = 0;
- cin >> n;
- vector<int> s(n);
- for (int i = 0; i < n; ++i) cin >> s[i];
- int a = 0, m = 0;
- cin >> a >> m;
- ll hash = 0;
- for (int value : s) {
- hash = (hash * a + value) % m;
- }
- cout << hash << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement