Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <iterator>
- #include <map>
- using namespace std;
- int main()
- {
- long long a;
- cin >> a;
- long long x;
- cin >> x;
- long long y;
- cin >> y;
- long long m;
- cin >> m;
- map<int, int> mymap;
- int pos = 1;
- mymap[a] = pos;
- pos++;
- while(true) {
- a = (x * a + y) % m;
- if(mymap[a] != 0) break;
- else mymap[a] = pos;
- pos++;
- }
- auto iter = mymap.find(a);
- cout << iter->first << " " << iter->second << endl;
- int it = iter->second - 1;
- cout << mymap.size() - it << " " << it;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement