题目链接
题目思路 【Codeforces Round #643 (Div. 2) C. Count Triangles 题解(思维)】显然是找x+y>z即可,其实只要枚举x+y即可,自己好菜qwq
代码
#include
#include
using namespace std;
typedef long long ll;
int a,b,c,d;
ll ans;
int main(){
scanf("%d %d %d %d",&a,&b,&c,&d);
for(int i=max(a+b,c);
i<=b+c;
i++){//枚举x+y
int l=max(a,i-c),r=min(b,i-b);
//枚举x的长度
ans+=1ll*(r-l+1)*(min(i-1,d)-c+1);
}
printf("%lld\n",ans);
return 0;
}
推荐阅读
- 每日一题|每日一题-解码(第十一届蓝桥杯)(简单思维)
- codeforces|Codeforces Round #665 (Div. 2) A. Distance and Axis(思维,数学)
- codeforces|Codeforces Global Round 10 C. Omkar and Waterslide(思维)
- codeforces|Codeforces Global Round 10 D. Omkar and Bed Wars(思维,分块)
- codeforces|Codeforces Round #643 (Div. 2) D. Game With Array (思维,贪心)
- codeforces|Codeforces Round #648 (Div. 2) C. Rotation Matching(思维)
- CodeForces - 245C Game with Coins
- #|C. Choosing flowers(枚举+思维+二分)
- #|A. Distance and Axis(思维) Codeforces Round #665 (Div. 2)