# NOIP Simulation Paper Shell

Source: Internet
Author: User

Task 1. Paper Shell (box.pas/box.c/box.cpp)"Title description"MCX is a child with a mild cleanliness. One day, when he was addicted to the math paper difficult to extricate themselves, vaguely think of their own learning probability of the time to prepare a pile of rubber also cluttered in the study room. This is clearly beyond his tolerance. So he decided to make a paper box with a volume of V (V=ABC) so that it could be placed neatly. For simplicity, the length, width, and height of the paper box are positive integers. Of course, MCX is a thrifty kid, so he wants to know what is the minimum surface area (S=2AB+2AC+2BC) of this paper box? "topic input"a single row, which is a positive integer V, represents the volume of the paper box. "topic output"a single row, which is a positive integer s, represents the minimum surface area of the paper box. "Sample input 1" -"Sample Output 1" -"Sample input 2"146"Sample Output 2"442"Sample Interpretation"The only way to make a box with a volume of 17 is to have a length of 1 width 1 high 17 (here we can think long, wide, high is equivalent), so its minimum surface area is 2*1*17+2*1*17+2*1*1 ="Data range"30% data Meets v<=1000100% data Meets V<=10^9Analysis:First of all! This is one! Math problem!! The math problem is going to have a math problem--it's much better than the other number-theoretic flirtatious problem. There is really no advanced solution to this problem. But to think about it is actually an enumeration. Enum A, after enumeration B, C comes out naturally. and just the method, blind basic, small data should be able to get points. the first optimization is to enumerate the A<=pow (V, 1.0/3) only when enumerating a, and enumerate only the preceding. and b is enumerated b<=sqrt (v/a);C can be calculated directly. Of course, it is not an integer judgment. The second optimization is when enumerating a. A pruning judgment on whether to enumerate B. We know that because at the time of enumeration A. V and a are fixed values. The surface area formula is the minimum value of the surface area of the v/a+a* (AB+BC+AC), which is changed into a (B+C) (b+c). We also know V/A==BC so BC is also fixed value so when b==c is the theoretical minimum value. So if we find a theoretical minimum, it's bigger than the answer we've enumerated. Then there's no need to enumerate B. Why B*c when B==c (b+c) is the smallest when it is a certain time? Here is a special thanks to the explanation of the Big uncle:

Post the Code:

`#include <cstdio> #include <algorithm> #include <cmath>using namespace Std;int main () {    freopen (" Box.in "," R ", stdin);    Freopen ("Box.out", "w", stdout);    int V;    Long long int ans=1000000000000000ll,bmj;    scanf ("%d", &v);    for (int a=v;a>=1;--a)    {        if ((v/a) *a!=v) continue;        int kk=sqrt (v/a);        bmj= (Long long int) (V/A+A*2*KK);        if (bmj<=ans| | A==V) {for            (int b=a;b<=a+kk;++b) {                int c=v/a/b;                if (c*a*b!=v) continue;                Ans=min (ans, (long long int) a*b+ (long long int) b*c+ (long long int) a*c);    }}} printf ("%i64d", 2*ans);    Fclose (stdin);    Fclose (stdout);    return 0;}`

NOIP Simulation Paper Shell

Related Keywords:
Related Article

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.