3249 Building Blocks
time limit: 1 sspace limit: 128000 KBtitle level: Golden Gold SolvingTitle Description
Description
Petya has a AXBXC box block, which is made up of small blocks of 1x1x1. Then the box has a height of a, a width of B, and a length of C. (^-^ Oh pro, remember that the length of the box is not necessarily larger than the width of the value of OH).
Now fun Petya a small box (A-1) x (B-2) x (C-2) is dug in the upper left corner of the box. and tells you that the volume of the box being dug is N, i.e. n= (A-1) x (B-2) x (C-2). Now ask what the minimum and maximum number of blocks of 1x1x1 are left after you are dug.
Beg Min{axbxc-n} and Max{axbxc-n}
Enter a description
Input Description
Enter a total of 1 rows with only a positive integer n.
Output description
Output Description
Output a total of 1 rows contain two positive integers separated by spaces, representing the minimum number of remaining block blocks and maximum remaining blocks.
Sample input
Sample Input
7
Sample output
Sample Output
47 65
Data range and Tips
Data Size & Hint
For 20% of data n≤400
For 50% of data n≤10^6
For 100% of data 1≤n≤10^9
#include <cstdio>#include<iostream>#include<algorithm>#defineMAX 9223372036854775807LLusing namespacestd;Long Longa=max,b=0;intN;intMain () {Long LongK; scanf ("%d",&N); for(intI=1; i*i*i<=n;i++){ if(n%i==0){ for(intj=i;j*j*i<=n;j++){ if(n/i%j==0) {k=n/i/J; A=min (A, (Long Long) (i+1) * (j+2) * (k +2)); A=min (A, (Long Long) (i+2) * (j+1) * (k +2)); A=min (A, (Long Long) (i+2) * (j+2) * (k +1)); b=max (b, (Long Long) (i+1) * (j+2) * (k +2)); b=max (b, (Long Long) (i+2) * (j+1) * (k +2)); b=max (b, (Long Long) (i+2) * (j+2) * (k +1)); } }}} printf ("%lld%lld\n", a-n,b-N); return 0;}
codevs3249 Building Blocks