题目链接:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2149 Accepted Submission(s): 897
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn=1e5+10; int n,m,k; int main() { while(scanf("%d%d%d",&n,&m,&k)!=EOF) { if(n>=2&&m>=2&&k>=2) { LL ans=n-2+m-2+k-2; printf("%lld\n",ans*6+15); } else { int a[4]; a[0]=n,a[1]=m,a[2]=k; sort(a,a+3); int num=0; for(int i=0;i<3;i++)if(a[i]==0)num++; if(num==3)printf("0\n"); else if(num==2) { if(a[2]==1)printf("0\n"); else printf("%d\n",a[2]*2-3); } else if(num==1) { if(a[2]==1)printf("1\n"); else { if(a[1]==1) { if(a[2]==1)printf("1\n"); else { LL ans=a[2]-2; printf("%lld\n",3*ans+3); } } else { LL ans=a[1]-2+a[2]-2; printf("%lld\n",ans*4+6); } } } else { if(a[2]==1)printf("3\n"); else { if(a[1]==1) { LL ans=a[2]-2; printf("%lld\n",6+ans*4); } else { LL ans=a[1]-2+a[2]-2; printf("%lld\n",5*ans+10); } } } } } return 0; }
原文:http://www.cnblogs.com/zhangchengc919/p/5926647.html