CTRL+A, CTRL+C, CTRL+V

Code given by does not give desired output.. pleas…

Anonymous - May 3, 2014

Code given by does not give desired output.. please check the code given below working fine.

int MaxCopy(int n){
int *table=(int *)malloc(sizeof(int)*(n+1));
memset(table,0,sizeof(int)*(n+1));

for(int i=0;i<=n;i++){
table[i]=i;
}
for(int i=0;i<=n;i++){
for(int j=i+4;j<=n;j++){
table[j]=max(table[j],table[i]*(j-i-2));
}
}
int res=table[n];
free(table);
return res;
}

Thanks man for fixing it. I will update it soon.

CTRL+A, CTRL+C, CTRL+V

Problem Imagine you have a special keyboard with the following keys:  A Ctrl+A Ctrl+C Ctrl+V where CTRL+A, CTRL+C, CTRL+V each acts as one function key for “Select All”, “Copy”, and “Paste” operations respectively. If you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys. That is to say, the input parameter is N (No. [Read More]

Polite Numbers - Calculate all the ways such that a number can be written as sum of 2 or more consecutive numbers

Problem Write a program that calculates all the ways that a number can be written as the sum of two or more consecutive numbers and generate those sets. Background  In number theory, a polite number is a positive integer that can be written as the sum of two or more consecutive positive integers. The first few polite numbers are 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17,… [Read More]