aboutsummaryrefslogtreecommitdiff
path: root/ThePowerSum.cpp
diff options
context:
space:
mode:
authorOmar Magdy <omar.professional8777@gmail.com>2022-05-30 00:18:17 +0200
committerOmar Magdy <omar.professional8777@gmail.com>2022-05-30 00:18:17 +0200
commit3a89fc707253f75f46fd5a4822817f1fd5156c40 (patch)
tree474b08b187895af91c10838aae21142b2ba2514d /ThePowerSum.cpp
parentf5ff62a26052f084b6b807cba220c86785fd45e3 (diff)
downloadcompetitive-programming-3a89fc707253f75f46fd5a4822817f1fd5156c40.tar.xz
competitive-programming-3a89fc707253f75f46fd5a4822817f1fd5156c40.zip
Made that every problem is its own folder to make building the code a smooth operation with a shortcut
Diffstat (limited to 'ThePowerSum.cpp')
-rw-r--r--ThePowerSum.cpp36
1 files changed, 0 insertions, 36 deletions
diff --git a/ThePowerSum.cpp b/ThePowerSum.cpp
deleted file mode 100644
index 7f7e032..0000000
--- a/ThePowerSum.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include<bits/stdc++.h>
-
-using namespace std;
-
-int power(int base, int p){
- if(p == 0) {
- return 1;
- }
- return base * (power(base, p - 1));
-}
-
-vector<int> ans;
-
-int powerSum(int x, int n, int lastDigit) {
- if (x == 0) {
- for(int x : ans) {
- cout << x << "^" << n << " + ";
- }
- cout << endl;
- return 1;
- }
- int sum = 0;
- for(int i = lastDigit; x - power(i, n) >= 0; i++) {
- ans.push_back(i);
- sum += powerSum(x - power(i, n), n, i + 1);
- ans.pop_back();
- }
- return sum;
-}
-
-int main() {
- int x, n, count = 0;
- cin >> x >> n;
- cout << powerSum(x, n, 1) << endl;
- return 0;
-}