codevs3249 Building Blocks

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.