CF571A - Lengthening Sticks(容斥)
来源:互联网 发布:windows程序设计第7版 编辑:程序博客网 时间:2024/05/17 07:33
//571A - Lengthening Sticks//数学题,容斥原理//总的选择数C(l+3,3) la+lb+lc+unused=l;//确定最长边,酱紫不构成三角形的充分必要条件就为 最长边>=其他两边和//枚举最长边增量i,其他两边为b+lb,c+lc//a+la>=b+lb+c+lc lb+lc<=l-la;//x=min(a+la-b-c,l-la);//则不构成三角形的数量为C(x+2,2);#include<cstdio>#include<algorithm>using namespace std;typedef long long LL;LL solve(int a,int b,int c,int l){ LL ans=0; for(int i=max(b+c-a,0);i<=l;i++){ LL x=min(a-b-c+i,l-i); ans+=(LL)(x+1)*(LL)(x+2)/2; } return ans;}int main(){ int a,b,c,l; scanf("%d%d%d%d",&a,&b,&c,&l); long long tot=(LL)(l+1)*(LL)(l+2)*(LL)(l+3)/6; tot-=solve(a,b,c,l); tot-=solve(b,a,c,l); tot-=solve(c,a,b,l); printf("%lld\n",tot); return 0;}
0 0
- CF571A - Lengthening Sticks(容斥)
- Lengthening Sticks 组合数+容斥原理
- Lengthening Sticks(容斥,组合数学)
- CodeForces #317 (div2) C.Lengthening Sticks (容斥)
- codeforces 571A--Lengthening Sticks(组合+容斥)
- C. Lengthening Sticks(Codeforces Round #317 容斥定理)
- Codeforces Round #317 A. Lengthening Sticks(组合+容斥)
- 容斥 + 组合数学 ---Codeforces Round #317 A. Lengthening Sticks
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) C Lengthening Sticks(组合+容斥)
- Codeforces div2 #317C Lengthening Sticks(组合数学+ 容斥原理)
- 571A Lengthening Sticks
- codeforces571A. Lengthening Sticks
- Lengthening Sticks CodeForces
- codeforces 571 A Lengthening Sticks
- Lengthening Sticks - Codeforces 571 A
- codeforces 571 A. Lengthening Sticks
- cf Div#317 Lengthening Sticks
- codeforces 317 A - Lengthening Sticks
- Repeater隔行变色,两个方式
- MySQL主从复制几个重要的参数
- 什么情况让程序员处于水生火热中
- storyboard中属性区域经常用的一些易混淆的属性
- IplImage结构
- CF571A - Lengthening Sticks(容斥)
- 解决拍照完成显示图片居然是被旋转的图片
- NSIS 的 Modern UI 教程(一)
- html块级元素与行内元素
- 【JS】JavaScript引擎的内部运行机制
- 华为老兵,聊聊我在华为的20年
- GDI+编程
- JSON入门指南
- static_cast, dynamic_cast, const_cast探讨