#include<bits/stdc++.h> using namespace std; int main() { long long int t,c,i; cin>>t; c=0; long long int a[100000]; for(i=1;i<100000;i++) { c=c+i; a[i]=c; } while(t--) { long int x,y,z,i,s; cin>>x>>y; z=x+y; s=a[z]; s++; s=s+x; cout<<s<<endl; } return 0; }
Asked by: Manish_Kumar_Savita on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.
See the constraints
1 ≤ U, V ≤ pow(10,9)
the maximum size of your array a is 100000. So in your code when (x+y)>=100000,segmentation fault(SIGSEGV) occurs.
z=x+y;
s=a[z];
I have no idea what made to choose this limit of 100000!
READ PROBLEM CONSTRAINTS CAREFULLY.!...When you are writing code try to understand what each line of your code does ...take your time. Don't just do stuff randomly hoping it would work out.