A.cpp 482 B

123456789101112131415161718192021222324
  1. //
  2. // Created by liuhuan on 18-11-7.
  3. //
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. int main(){
  7. int n;
  8. while(cin>>n){
  9. long long m=2*n;
  10. int a=floor(sqrt(m));
  11. for(int b=a;b>0;b--){
  12. if(m%b)continue;
  13. int p=b,q=m/b;
  14. int j=(p+q-1)/2;
  15. int i=(q-p+1)/2;
  16. if(j>i&&i+j==q&&j-i+1==p)
  17. {
  18. cout<<i<<" "<<j<<endl;
  19. }
  20. }
  21. cout<<endl;
  22. }
  23. return 0;
  24. }