poj 2363 Blocks

//暴力0ms通过,题目的意思是:包装这些立方体所需要的包装纸的最小表面积! 
#include<iostream>
#include<climits>
using namespace std;

int main()
{
    int tc, cube, i, a, b, c, min, tmp;
    cin >> tc;
    while (tc--){
          cin >> cube;
          min = INT_MAX;
          for (a = 1; a <= cube; a++)//因为少了一个等号,WA了两次! 
            for (b = 1; b <= cube/a; b++){
                if (cube%(a*b) == 0){
                     c = cube / (a*b);
                     tmp = a * b * 2 + a * c * 2 + b * c * 2;
                     if (tmp < min)
                        min = tmp;
                }
            }
          cout << min << endl;
    }
    system("pause");
}

你可能感兴趣的:(c,System)