标签:测试数据 ges class std ret www. hid efi font
现在有三根木棒,他们的长度分别是a,b,c厘米。你可以对他们进行加长(不同的木棒可以增加不同的长度),他们总的加长长度不能超过L厘米。你也可以不对他们进行加长。
现在请你计算一下有多少种加长的方式使得他们能构成合法的三角形(面积非0)。
单组测试数据。 共一行,包含4 个整数a,b,c,L (1≤a,b,c≤3*10^5, 0≤L≤3*10^5)。
输出答案占一行。
1 1 1 2
4
1 #include <cstdio> 2 #include <cctype> 3 #define min(a,b) a<b?a:b 4 5 typedef long long LL; 6 7 LL a,b,c,l; 8 9 inline void read(LL&x) { 10 int f=1;register char c=getchar(); 11 for(x=0;!isdigit(c);c==‘-‘&&(f=-1),c=getchar()); 12 for(;isdigit(c);x=x*10+c-48,c=getchar()); 13 x=x*f; 14 } 15 16 inline LL NOT(LL a,LL b,LL c,LL l) { 17 LL cnt=0; 18 for(int z=0;z<=l;++z) { 19 LL x=min(c+z-a-b,l-z); 20 if(x>=0) cnt+=(x+1)*(x+2)/2; 21 } 22 return cnt; 23 } 24 25 int hh() { 26 read(a);read(b);read(c);read(l); 27 LL ans=(l+3)*(l+2)*(l+1)/6; 28 ans-=NOT(a,b,c,l); 29 ans-=NOT(a,c,b,l); 30 ans-=NOT(b,c,a,l); 31 printf("%lld\n",ans); 32 return 0; 33 } 34 35 int sb=hh(); 36 int main(int argc,char**argv) {;}
标签:测试数据 ges class std ret www. hid efi font
原文地址:http://www.cnblogs.com/whistle13326/p/7647603.html