题意:给你n=
(A - 1) × (B - 2) × (C - 2),求A*B*C的最大值和最小值
View Code
思路:要用好的姿势暴力
1 #include "stdio.h" 2 #include "string.h" 3 #define inf 10000000000 4 int main() 5 { 6 long long i,j,k,min,max,n; 7 while(scanf("%I64d",&n)==1) 8 { 9 min=inf; 10 max=(n+1)*9-n; 11 for(i=1;i*i*i<=n;i++) 12 { 13 if(n%i==0) 14 { 15 for(j=i;j*j<=n/i;j++) 16 if((n/i)%j==0) 17 { 18 if((i+1)*(j+2)*(n/i/j+2)-n<min) 19 min=(i+1)*(j+2)*(n/i/j+2)-n; 20 } 21 } 22 } 23 printf("%I64d %I64d\n",min,max); 24 } 25 return 0; 26 }