summaryrefslogtreecommitdiff
path: root/introductory_problems/bit_strings.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-02-13 15:11:28 -0700
committerJack Sangdahl <[email protected]>2025-02-13 15:11:28 -0700
commit19bb82f44e8da0ab854f93248a8fe72d430b46e4 (patch)
tree997771564cbee9ee34a1100c4d26019b40b20a2b /introductory_problems/bit_strings.cpp
parent146f58d5d91133e43045df719b3f0ae7ad1266f0 (diff)
downloadcses-19bb82f44e8da0ab854f93248a8fe72d430b46e4.tar.gz
cses-19bb82f44e8da0ab854f93248a8fe72d430b46e4.zip
1617. bit strings
Diffstat (limited to 'introductory_problems/bit_strings.cpp')
-rw-r--r--introductory_problems/bit_strings.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/introductory_problems/bit_strings.cpp b/introductory_problems/bit_strings.cpp
new file mode 100644
index 0000000..84acfea
--- /dev/null
+++ b/introductory_problems/bit_strings.cpp
@@ -0,0 +1,21 @@
+// 1617. Bit Strings
+#include <bits/stdc++.h>
+
+const int mod = 1e9 + 7;
+
+long long fast_pow2(int x) {
+ long long res = 1, y = 2;
+ while (x) {
+ if (x & 1)
+ res = (res * y) % mod;
+ y = (y * y) % mod;
+ x >>= 1;
+ }
+ return res;
+}
+
+int main() {
+ static int n;
+ scanf("%d", &n);
+ printf("%lld\n", fast_pow2(n));
+}