首页 > 其他分享 >Codeforces Round #643 (Div. 2) C

Codeforces Round #643 (Div. 2) C

时间:2022-10-27 19:55:23浏览次数:39  
标签:const int Codeforces long 643 return Div 998244353

C. Count Triangles

显然两边之和大于第三边
我们可以先预处理出来这个两边之和
我们暴力枚举x 然后区间赋值[x+b,x+c]+1
然后最后暴力枚举第三个边 然后将大于第三边的方案数加上就是了

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
const int M = 998244353;
const int mod = 998244353;
#define int long long
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define _ 0
#define pi acos(-1)
#define INF 0x3f3f3f3f3f3f3f3f
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
int s[N];
void solve(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    for(int x=a;x<=b;x++){
        s[x+b]++,s[x+c+1]--;
    }
    for(int i=0;i<=1e6;i++)s[i]+=s[i-1];
    for(int i=0;i<=1e6;i++)s[i]+=s[i-1];
    int ans=0;
    for(int z=c;z<=d;z++){
        ans+=s[N-10]-s[z];
    }
    cout<<ans<<endl;
}
signed main(){
    fast
    int t;t=1;//cin>>t;
    while(t--) {
        solve();
    }
    return ~~(0^_^0);
}

标签:const,int,Codeforces,long,643,return,Div,998244353
From: https://www.cnblogs.com/ycllz/p/16833524.html

相关文章

  • P4349 [CERC2015]Digit Division
    题目传送门思路以下纯考场思路。今天模拟赛考到了这题的加强版,然后预处理写炸了,\(100\)变成\(70\),当是给CSP攒rp了。首先一眼看到题目可能会没有思路,没什么关系,......
  • Codeforces Round #673 (Div. 2) C. k-Amazing Numbers
    题面Youaregivenanarrayaconsistingofnintegersnumberedfrom1ton.Let’sdefinethek-amazingnumberofthearrayastheminimumnumberthatoccurs......
  • Codeforces Round #828 (Div. 3) A-F
    比赛链接A题解知识点:贪心,模拟。遇到没用过的数字就给个字母,遇到用过的数字就对照字母是否一致。时间复杂度\(O(n)\)空间复杂度\(O(n)\)代码#include<bits/stdc+......
  • Codeforces Round #632 (Div. 2) / 1333C】- C. Eugene and an array
    题面Eugenelikesworkingwitharrays.Andtodayheneedsyourhelpinsolvingonechallengingtask.Anarrayccisasubarrayofanarraybbifcccanbeobta......
  • Codeforces Round #725 (Div. 3) ABC(双指针)F
    https://codeforces.com/contest/1538AB都没啥好说的,C卡了半天,F挺好写的,找到规律了就直接ac1300的题目卡半天,1500的题目写的顺顺利利,真呆啊我A.StoneGame#include<......
  • Codeforces Round #619 (Motarack's Birthday)
    题面DarkisgoingtoattendMotarack’sbirthday.DarkdecidedthatthegiftheisgoingtogivetoMotarackisanarrayaofnnon-negativeintegers.Darkcr......
  • Codeforces Round #829 (Div. 2)
    Contest链接E题意简述给长为\(n\)序列,随机等概率交换两个不同位置(\(i<j\))的值,要求\(a_i>a_j\)时才能交换。\(n\le200000\)像这个题但是强制要求\(a......
  • Codeforces 1672 E. notepad.exe
    题意这是一道交互题,有n个字符串,每个字符串长度:0-2000,n:0-2000有一个机器对他进行排版,你可以给他一个每行的最大宽度w,那么每行只能放长度为w的字符;每行相邻两个字符......
  • Codeforces Round #690 (Div. 3) F
    F.TheTreasureofTheSegments理解题意就是要让我们找一个线段+他相交的所有线段max我们暴力枚举线段然后用sum-不相交的不相交的就好算了只有两种情况一个线段左......
  • CF Round #829 题解 (Div. 2)
    F没看所以摆了.看拜月教教主LHQ在群里代打恰钱/bx目录A.TechnicalSupport(*800)B.KevinandPermutation(*800)C.MakeNonzeroSum(C1*1300,C2*1500)D.F......