标签:long int pac max 最大值 main 题意 namespace a*
C. Help Farmer
简化题意:已知abc=N,给出N,求解出
\[ (a+2)*(b+2)*(c+1) 的最大值和最小值 \]
题解:暴力枚举a,b,c,求出最小值。
默认
\[ 最大值 =3*3*(N+1) \]
#include <cstdio>
#include <queue>
using namespace std;
typedef long long ll;
ll min(ll a,ll b){
return a<b?a:b;
}
ll max(ll a,ll b){
return a>b?a:b;
}
int main(){
ll N;
scanf("%lld",&N);
ll minn=3*3*(N+1);
for(ll a=1;a<=100000;a++){
if(N%a==0)
for(ll b=1;b<=10000;b++){
if(N%(a*b)==0){
ll c=N/a/b;
minn=min(minn,(min(min(a,b),c)+1)*(max(max(a,b),c)+2)*
(a+b+c-min(min(a,b),c)-max(max(a,b),c)+2));
}
}
}
printf("%lld",minn-N);
printf(" %lld\n",3*3*(N+1)-N);
return 0;
}
【CoreForces Round #102B】 Help Farmer
标签:long int pac max 最大值 main 题意 namespace a*
原文地址:https://www.cnblogs.com/Vagrant-ac/p/12149257.html