We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5f35b9 commit ceef603Copy full SHA for ceef603
07 - Other Concepts/08 - Bit Array/main.cpp
@@ -0,0 +1,28 @@
1
+#include <iostream>
2
+#include <algorithm>
3
+#include <unordered_set>
4
+using namespace std;
5
+
6
7
+int main() {
8
+ int N, S, P, Q;
9
+ int mod = (1 << 31);
10
11
12
+ int tortoise = S % mod;
13
+ int here = tortoise;
14
15
+ int count = 0;
16
17
+ while(count < N){
18
+ count++;
19
+ tortoise = (tortoise * P + Q) % mod;
20
21
+ here = (here * P + Q) % mod;
22
23
24
+ if(here == tortoise) break;
25
+ }
26
+ cout<< count;
27
+ return 0;
28
+}
0 commit comments