diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-11-05 01:41:11 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-11-05 01:41:11 +0200 |
| commit | 7f856c7ff080b8d455b9ed16c2e57dd862c3879d (patch) | |
| tree | c2baf90f98c91567358003d6b97a4afed7fa9b42 /ThePowerSum/ThePowerSum.cpp | |
| parent | c52b36c6a37fdb1d1de146d3939cb42e2c691f44 (diff) | |
| download | competitive-programming-7f856c7ff080b8d455b9ed16c2e57dd862c3879d.tar.xz competitive-programming-7f856c7ff080b8d455b9ed16c2e57dd862c3879d.zip | |
moved some file
Diffstat (limited to 'ThePowerSum/ThePowerSum.cpp')
| -rw-r--r-- | ThePowerSum/ThePowerSum.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/ThePowerSum/ThePowerSum.cpp b/ThePowerSum/ThePowerSum.cpp deleted file mode 100644 index 7f7e032..0000000 --- a/ThePowerSum/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; -} |
