Hi, I came across one question from codechef. [Click Here](http://www.codechef.com/problems/J7) Here, we are given P and S. Let l, b, h be the length, breadth, height of the box. we have these two inequalities 4*(l+b+h) <= P 2*(l*b+b*h+h*l) <= S We have to maximise the volume which is l*b*h. We are also given that test cases will produce optimal solution. Can any 1 please help me with it?

Member Avatar
Member Avatar
+0 forum 3

#include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int compare(const void * a, const void * b) { return strcmp(a, b); } struct node { char name[51]; int index; }; /* 1.Sort the Array cities (which was copy of A) and Array B2 (which was copy of B). 2.Do binary search in sorted array B (called B2) to find a city in A which is not present in B2. 3.If the index found is i, then print "A[i] B[i] cost[i]$". 4.Do this for n - 2 times : For each B[indx], find it in sorted array cities and use its …

Member Avatar
Member Avatar
+0 forum 3

http://www.codechef.com/problems/NUKES I'm getting time limit exceeded in my code... Please some one help me out with this code. My algorithm is when A - ((N+1) ^ (p+1)) < 0 then pth chamber will have 1 particle and the new value of A in my recursive function is A - ((N+1) ^ p). This process will continue till A < N+1, then k[0] will be A. #include <stdio.h> #include <math.h> int k; int N; /* if [A - (N + 1) ^ (p + 1) < 0], then pth chamber will have one particle and new value of A i.e. A' …

Member Avatar
Member Avatar
+0 forum 12

[CODE] #include <iostream> #include<stdio.h> #include<string.h> using namespace std; int main() { // cout << "Hello world!" << endl; int t,i,j,a,flag; char str[1000001]; cin>>t; while(t--) { a=1; scanf("%s",str); for(i=0;i<=strlen(str);i++) {flag=0; if(!isdigit(str[i])) {flag=0; for(j=i-1;isdigit(str[j]);j--) { if(str[j]!='0') { flag++; a*=str[j]-'0'; //cout<<"flag"<<flag<<" "<<a<<"A"<<endl; break; } } if(flag==0) { a=0;break; } } while(a>9) { if((a%10)!=0) { a=a%10; //cout<<"a"<<a<<endl; } else { a=a/10; } } } if(a) printf("%d\n",a); else printf("Robot hanged.\n"); } return 0; } [/CODE] This is the code for the following problem [URL="http://www.codechef.com/problems/TESTTT5"]link[/URL]. I am getting a wrong answer despite my code working for all the test cases. Can anyone tell me for which …

Member Avatar
Member Avatar
+0 forum 1

The End.