void problem(int n){ switch(n){ case 123:{ //int a[] = {-2 , 1 , -3 , 4 , -1 , 2 , 1 , -5 , 4}; int a[] = {1 , 2 , 3 , 0 , 2}; int len = sizeof(a) / sizeof(int); vector<int> in(a , a + len); cout << maxProfit2(in) << endl; } break; case 121:{ //int a[] = {-2 , 1 , -3 , 4 , -1 , 2 , 1 , -5 , 4}; int a[] = {1 , 2 , 3 , 0 , 2}; int len = sizeof(a) / sizeof(int); vector<int> in(a , a + len); cout << maxProfit(in) << endl; } break; case 279:{ cout << numSquares(12) << endl; cout << numSquares(13) << endl; } break; case 309:{ //int a[] = {-2 , 1 , -3 , 4 , -1 , 2 , 1 , -5 , 4}; int a[] = {1 , 2 , 3 , 0 , 2}; int len = sizeof(a) / sizeof(int); vector<int> in(a , a + len); cout << maxProfit_cooldown(in) << endl; } break; case 343:{ cout << integerBreak(5) << endl; cout << integerBreak(10) << endl; } break; case 338:{ showVector(countBits(5)); showVector(countBits(15)); } break; case 70:{ cout << climbStairs(5) << endl; cout << climbStairs(15) << endl; cout << climbStairs(8) << endl; } break; case 53:{ //int a[] = {-2 , 1 , -3 , 4 , -1 , 2 , 1 , -5 , 4}; int a[] = {-2 , -1 , -3}; int len = sizeof(a) / sizeof(int); vector<int> in(a , a + len); cout << maxSubArray(in) << endl; } break; default: break; } }
long long integerBreak(long long n) { if(n == 2) return 1; if(n == 3) return 2; if(n == 4) return 4; if(n == 5) return 6; if(n == 6) return 9; return 3 * integerBreak(n - 3); }
int integerBreak(int n) { if (n == 1) { return 1; } else if (n == 2) { return 1; } else if (n == 3) { return 2; } else if (n == 4){ return 4; } else if (n == 5) { return 6; } else if (n == 6) { return 9; } else { return 3 * integerBreak(n - 3); } }