Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<fstream>
- #include<vector>
- #include<string>
- #include<algorithm>
- #define long long long
- #define nln '\n'
- const long BASE = 311;
- const long MOD = 1e9 + 3;
- using namespace std;
- // GLobal variables: f1, f2, st1, st2
- fstream f1,f2;
- inline void openf()
- {
- f1.open("prefix.inp", ios:: in);
- f2.open("prefix.out", ios:: out);
- }
- inline void closef()
- {
- f1.close();
- f2.close();
- }
- string st1, st2;
- long hst1 = 0;
- long hst2 = 0;
- void data()
- {
- f1.tie(0)->sync_with_stdio(0);
- f2.tie(0)->sync_with_stdio(0);
- cin >> st1 >> st2;
- for (long i = 0; i != st1.size(); ++i)
- {
- hst2 = ((hst2*BASE) + st2[i] - 'a') % MOD;
- hst1 = ((hst1*BASE) + st1[i] - 'a') % MOD;
- }
- }
- void process()
- {
- if (hst1 == hst2)
- cout << "Yes" << nln;
- else
- cout << "No" << nln;
- }
- void view()
- {
- }
- int main()
- {
- openf();
- data();
- process();
- view();
- closef();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment