[组合] Codeforces #571A. Lengthening Sticks
来源:互联网 发布:淘宝推荐话术 编辑:程序博客网 时间:2024/05/17 03:25
一开始正着做很复杂,然后发现补集转化一下就很方便了,随便搞一下…
#include<cstdio>#include<algorithm>using namespace std;const int maxn=100005;typedef long long LL;int a,b,c,L,d;LL ans;LL get(int a,int b,int c){ int x=min(L+a-d,d-b-c); return x<0?0:(LL)(x+2)*(x+1)/2;}int main(){ freopen("cf571A.in","r",stdin); freopen("cf571A.out","w",stdout); scanf("%d%d%d%d",&a,&b,&c,&L); int _max=max(a,max(b,c)); ans=(LL)(L+3)*(L+2)/2*(L+1)/3; for(d=_max;d<=_max+L;d++){ ans-=get(a,b,c)+get(b,a,c)+get(c,a,b); //printf("%d: %d\n",d,get(a,b,c)+get(b,a,c)+get(c,a,b)); } printf("%I64d\n",ans); return 0;}
阅读全文
0 0
- [组合] Codeforces #571A. Lengthening Sticks
- codeforces 571 A Lengthening Sticks
- Lengthening Sticks - Codeforces 571 A
- codeforces 571 A. Lengthening Sticks
- codeforces 571A--Lengthening Sticks(组合+容斥)
- Codeforces Round #317 A. Lengthening Sticks(组合+容斥)
- 容斥 + 组合数学 ---Codeforces Round #317 A. Lengthening Sticks
- 571A Lengthening Sticks
- codeforces 317 A - Lengthening Sticks
- Codeforces Round #317 (Div. 2) 571A. Lengthening Sticks 组合数学
- 51NOD 1509 加长棒 && Codeforces 571 A. Lengthening Sticks(组合数学 + 挡板法)
- Codeforces Round #317 A.Lengthening Sticks
- Lengthening Sticks CodeForces
- [思路题] cf 571A Lengthening Sticks
- 【codeforces 572C】Lengthening Sticks
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) C Lengthening Sticks(组合+容斥)
- Codeforces div2 #317C Lengthening Sticks(组合数学+ 容斥原理)
- CF#317-C. Lengthening Sticks-组合数学
- 4033: [HAOI2015]树上染色
- android的四种启动方式
- 素数判断&&求m内能被3整除的所有数之和
- VS2013 CAFFE CUDNNV6 CUDA V8.0配置
- 区间DP心得及例题
- [组合] Codeforces #571A. Lengthening Sticks
- 代码开光
- 二次整数分解
- shell中流程的控制
- opencv基础函数汇总
- 创建继承类Person的类Student
- CPU使用率 VS Load
- bzoj2435 道路修建
- 274. H-Index解题报告