2 条题解

  • 0
    @ 2026-5-17 14:34:11
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int tt;
        cin>>tt;
        while(tt--){
            ll l,r;
            cin >>l>>r;
            ll ans=0;
            if(r>=2*l)
                ans=(r-2*l+1)*(r-2*l+2)/2;
            cout<<ans<<endl;
        }
        return 0;
    }
    
    • 0
      @ 2026-5-17 14:34:00
      #include <bits/stdc++.h>
      
      using namespace std;
      
      #define ll long long
      
      int main() {
          ios::sync_with_stdio(0);
          cin.tie(0);
          int tt;
          cin >> tt;
          while(tt--){
              ll l, r;
              cin >> l >> r;
              ll ans = 0;
              if(r >= 2 * l)
                  ans = (r - 2 * l + 1) * (r - 2 * l + 2) / 2;
              cout << ans << '\n';
          }
          return 0;
      }
      • 1

      信息

      ID
      9295
      时间
      2000ms
      内存
      1024MiB
      难度
      9
      标签
      递交数
      12
      已通过
      6
      上传者