Advertisement
SelinD

v72s3e3

Feb 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int ecuatie(int a,int b,int c)
  6. {
  7. int delta;
  8. delta=b*b-4*a*c;
  9. if(delta>=0) return (-b+sqrt(delta))/2*a;
  10. return -32000;
  11. }
  12. int main()
  13. {
  14. int k,g,t;
  15. cin>>k;
  16. g=ecuatie(1,1,-2*k);
  17. if(g*(g+1)==2*k)
  18. t=g;
  19. else
  20. t=k-g*(g+1)/2;
  21. cout<<t;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement