Christmas Gift

PROBLEM LINK https://www.codechef.com/FXBG2020/problems/FTB006
PROBLEM NAME-CHRISTMAS GIFT
AUTHOR-@dishan2925
DIFFICULTY-EASY
CONTEST-CLADDING THE CODE
ORGANIZER-ROBOTICS CLUB MMMUTp
SOLUTION
After analysing the question it is clear that the main motive of question is to find the minimal cost of the delivery . In this problem we have to find the minimum cost for packaging of a cuboid box containg N glass cube gifts.
Minimal cost is calculated by the formula (l+b+h) Here, l b and h are the dimensions of the cuboid box in which glass gifts are packed.
Therefore we have to to arrange length breadth and height of cuboid box such that their sum is minimum.
Code-

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll sc,i,n,min,c,ns,j,x;
    cin>>x;
    while(x--)
	{
	cin>>sc;
    for(i=0;i<sc;i++)
    {
       n=sc;
       min=99999;
       ns=sqrt(n);
       c=0;
       for(j=2;j<=ns;j++)
       {
           if( n % j == 0)
           {
               c++;
               break;
           }
       }
       if(c==0)
       min = n+2 ;
       else
       {
           for(j=1;j<=n/2;j++)
           {
               if(n%j == 0)
               for(ll k=1;k<=n/2;k++)
               {
                   if(n%k==0)
                   for(ll l=1;l<=n/2;l++)
                   {
                       if(j*k*l == n && (j+k+l <= min))
                       {
                            min=j+k+l;
                       }
                   }
               }
           }
       }
    }
    cout<<min<<"\n";
    }
    return 0;
}