Created
September 29, 2017 15:42
-
-
Save maple3142/788f13420d8cb6eb2179789613bfeb07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int sum(int a,int b){ | |
return (a+b)*(b-a+1)/2; | |
} | |
int main(void){ | |
ios::sync_with_stdio(false); | |
int n; | |
while(cin>>n){ | |
int cnt=0; | |
int s=1,e=1; | |
while(e<n&&s<=e){ | |
int r=sum(s,e); | |
if(r==n){ | |
cout<<s<<" "<<e<<endl; | |
cnt++; | |
s++; | |
} | |
else if(r>n){ | |
s++; | |
} | |
else if(r<n){ | |
e++; | |
} | |
} | |
cout<<cnt<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment