Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <set>
- using namespace std;
- int main()
- {
- int x, n;
- cin >> x >> n;
- set<int> st;
- int cur = x;
- st.insert(x);
- for(int i = 0; i < 100000; i++) {
- cur = ((x * cur)%n);
- st.insert(cur);
- }
- cout << st.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment