~cpp #include <iostream> using namespace std; #include <vector> #include <cmath> unsigned int hanoi[10001] = {0,1,}; int a[10000]; int main() { vector<int> test; int num; unsigned min, temp; for(int i = 1; i < 10001; i++) { min = 4000000000; for(int k = 0; k < i; k++) { temp = 2*hanoi[k] +pow(2,i-k) -1; if(temp <= min) { min = temp; a[i] = k; } } hanoi[i] = min; } for(i = 1; i < 30; i++) cout << i << " " << a[i] << " " << hanoi[i] << endl; while(cin >> num) test.push_back(num); for(vector<int>::iterator j = test.begin(); j != test.end(); j++) cout << hanoi[*j] << endl; return 0; }