We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main() {
long long N, S, P, Q;
cin >> N >> S >> P >> Q;
set<long long> uniqueNumbers;
long long current = S;
for (long long i = 0; i < N; ++i) {
uniqueNumbers.insert(current);
current = (current * P + Q) % (1LL << 31);
}
cout << uniqueNumbers.size() << endl; // Output the number of distinct integers
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Bit Array
You are viewing a single comment's thread. Return to all comments →
my code
include
include
using namespace std;
int main() { long long N, S, P, Q; cin >> N >> S >> P >> Q;
}