1371B - Magical Calendar - CodeForces Solution


math *1200

Please click on ads to support us..

Python Code:

for  s in[*open(0)][1:]:n,r=map(int,s.split());print((n*n-n+2,r*r+r)[n>r]//2)

C++ Code:

#include<bits/stdc++.h>
#define ll long long
const ll N = 2e5+5;
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        ll n, r;
        cin>>n>>r;
        cout<<1ll*min(n*(n-1)/2+1, r*(r+1)/2)<<endl;
    }
}


Comments

Submit
0 Comments
More Questions

1459B - Move and Turn
1006F - Xor-Paths
706C - Hard problem
304C - Lucky Permutation Triple
1301C - Ayoub's function
38E - Let's Go Rolling
171G - Mysterious numbers - 2
1183C - Computer Game
400C - Inna and Huge Candy Matrix
417A - Elimination
222A - Shooshuns and Sequence
1736A - Make A Equal to B
1736B - Playing with GCD
887C - Solution for Cube
1737C - Ela and Crickets
1741C - Minimize the Thickness
1741A - Compare T-Shirt Sizes
1741D - Masha and a Beautiful Tree
109B - Lucky Probability
1741B - Funny Permutation
1741E - Sending a Sequence Over the Network
344B - Simple Molecules
370A - Rook Bishop and King
546E - Soldier and Traveling
1741G - Kirill and Company
1200B - Block Adventure
1088B - Ehab and subtraction
1270B - Interesting Subarray
478C - Table Decorations
1304C - Air Conditioner