Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int ecuatie(int a,int b,int c)
- {
- int delta;
- delta=b*b-4*a*c;
- if(delta>=0) return (-b+sqrt(delta))/2*a;
- return -32000;
- }
- int main()
- {
- int k,g,t;
- cin>>k;
- g=ecuatie(1,1,-2*k);
- if(g*(g+1)==2*k)
- t=g;
- else
- t=k-g*(g+1)/2;
- cout<<t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement