aboutsummaryrefslogtreecommitdiff
path: root/cses/WeirdAlgorithm
diff options
context:
space:
mode:
Diffstat (limited to 'cses/WeirdAlgorithm')
-rwxr-xr-xcses/WeirdAlgorithm/mainbin0 -> 22544 bytes
-rw-r--r--cses/WeirdAlgorithm/main.cpp19
-rw-r--r--cses/WeirdAlgorithm/main_input0.txt1
-rw-r--r--cses/WeirdAlgorithm/main_output0.txt1
4 files changed, 21 insertions, 0 deletions
diff --git a/cses/WeirdAlgorithm/main b/cses/WeirdAlgorithm/main
new file mode 100755
index 0000000..39ec9c4
--- /dev/null
+++ b/cses/WeirdAlgorithm/main
Binary files differ
diff --git a/cses/WeirdAlgorithm/main.cpp b/cses/WeirdAlgorithm/main.cpp
new file mode 100644
index 0000000..ab5b099
--- /dev/null
+++ b/cses/WeirdAlgorithm/main.cpp
@@ -0,0 +1,19 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ long long n;
+ cin >> n;
+ while (n != 1) {
+ cout << n << " ";
+ if (n % 2 == 0) {
+ n /= 2;
+ } else {
+ n = n * 3 + 1;
+ }
+ }
+ cout << 1;
+}
diff --git a/cses/WeirdAlgorithm/main_input0.txt b/cses/WeirdAlgorithm/main_input0.txt
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/cses/WeirdAlgorithm/main_input0.txt
@@ -0,0 +1 @@
+3
diff --git a/cses/WeirdAlgorithm/main_output0.txt b/cses/WeirdAlgorithm/main_output0.txt
new file mode 100644
index 0000000..4c544cf
--- /dev/null
+++ b/cses/WeirdAlgorithm/main_output0.txt
@@ -0,0 +1 @@
+3 10 5 16 8 4 2 1