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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. C++
  3. Other Concepts
  4. Bit Array

Bit Array

Problem
Submissions
Leaderboard
Discussions
Editorial

You are given four integers: , , , . You will use them in order to create the sequence with the following pseudo-code.

a[0] = S (modulo 2^31)
for i = 1 to N-1
    a[i] = a[i-1]*P+Q (modulo 2^31) 

Your task is to calculate the number of distinct integers in the sequence .

Input Format

Four space separated integers on a single line, , , , and respectively.

Output Format

A single integer that denotes the number of distinct integers in the sequence .

Constraints



Sample Input

3 1 1 1

Sample Output

3

Explanation

Hence, there are different integers in the sequence.

Author

ikbalkazar

Difficulty

Hard

Max Score

80

Submitted By

38787

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy