forked from adarshpandey10t/Hacktoberfestmine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChristmas Gift.cpp
More file actions
49 lines (49 loc) · 956 Bytes
/
Christmas Gift.cpp
File metadata and controls
49 lines (49 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#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;
}