fork download
  1. #include <iostream>
  2. #include<math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. long int t;double n,m;int flag=0;int pos;int ctr=0,sum;
  8. cin>>t;
  9. for(int i=0;i<t;i++)
  10. {cin>>n>>m;sum=0;flag=0;pos=0;
  11. ctr=0;
  12. for(int j=1;j<=n;j++)
  13. {sum+=j;
  14. if(sum>=m&&ctr==0)
  15. {ctr++;flag=1;pos=j;}
  16. }
  17. if(flag==1)
  18. {cout<<pos<<endl;}
  19. else
  20. {cout<<sum-m<<endl;}
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
-2.33374e-310
-2.33374e-310