cubequoc
quoc14
c_cpp
a month ago
1.4 kB
2
Indexable
Never
caidat
50 88236 48656 13459 11728 36174 30156 4852 20681 30537 86072 90017 117168 37756 64019 100162 43119 11136 13121 10356 78102 101127 82690 81340 62017 34651 124902 29776 82925 100821 3244 124546 38922 119326 123570 22936 103654 70963 36213 113709 69648 76626 79011 84170 119374 66214 36590 71902 4877 109837 51232 // Online C++ compiler to run C++ program online #include <iostream> using namespace std; int cube[51]; int n, x; int ans; void backtrack(int index, int total, int x) { if (x == 0) return; if (index > 5) { //cout << "to" << endl; if (total == n) ans++; return; } if (total == n) { //cout << "quoc" << endl; ans++; return; } int tmp = total + cube[x]; if (tmp <= n) { backtrack(index + 1, tmp, x); } backtrack(index, total, x - 1); } void solve(int testcase) { cin >> n; for (int i = 1; i <= 50; i++) { x = i; if (cube[i] > n) { break; } } ans = 0; //cout << x << endl; backtrack(1, 0, x); cout << "#" << testcase << " " << ans << endl; } int main() { for (int i = 0; i <= 50; i++) { cube[i] = i * i * i; } int t; cin >> t; for (int i = 1; i <= t; i++) { solve(i); } return 0; }
Leave a Comment