Tell me whats wrong in this approach to this problem i wrote for this problem I am just a beginner.↵
↵
~~~~~↵
↵
~~~~~↵
↵
#include<iostream>↵
using namespace std;↵
↵
int main(){↵
long long int t;↵
cin>>t;↵
while (t--)↵
{↵
long long int x , y;↵
cin>>x>>y;↵
↵
if(x == y) cout<<x*(x-1) + 1<<"\n" ;↵
if(x>y) ↵
{↵
long long int diag = x*(x -1) +1;↵
cout<<diag + (x - y)<<"\n";↵
}↵
if(x<y) cout<< y*(y-1) + 1 + (y-x)<<"\n";↵
}↵
~~~~~↵
↵
~~~~~↵
↵
↵
↵
~~~~~↵
↵
~~~~~↵
↵
#include<iostream>↵
using namespace std;↵
↵
int main(){↵
long long int t;↵
cin>>t;↵
while (t--)↵
{↵
long long int x , y;↵
cin>>x>>y;↵
↵
if(x == y) cout<<x*(x-1) + 1<<"\n" ;↵
if(x>y) ↵
{↵
long long int diag = x*(x -1) +1;↵
cout<<diag + (x - y)<<"\n";↵
}↵
if(x<y) cout<< y*(y-1) + 1 + (y-x)<<"\n";↵
}↵
~~~~~↵
↵
~~~~~↵
↵
↵