Advertisement
Guest User

Untitled

a guest
May 13th, 2012
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <set>
  7. #include <string>
  8. using namespace std;
  9. int main(){
  10. long long n;
  11. cin >> n;
  12. long long k=0;
  13. long long j=n/2;
  14. if ( sqrt ( double ( n ) ) == int ( sqrt ( double ( n ) ) ) ) {
  15. cout << '1';
  16. return 0;
  17. }
  18. for (i=0;k<j;i++)
  19. {
  20. k += 2 * i + 1;
  21. if ( sqrt ( double ( n-k ) ) == int ( sqrt ( double ( n-k ) ) ) ) {
  22. cout << '2';
  23. return 0;
  24. }
  25. }
  26. while ( n % 4 == 0) n /= 4;
  27. if (n % 8 == 7) cout << '4';
  28. else cout << '3';
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement