Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. bool isSquare(long long n){
  8. long long squareRootN=(long long)round((sqrt(n)));
  9.  
  10. if(squareRootN*squareRootN == n) {
  11. return true;
  12. }
  13. else {
  14. return false;
  15. }
  16. }
  17. int main(){
  18. long long n;
  19.  
  20. cin>>n;
  21. int count = 0;
  22. for (long long i = 1; i<n; i++){
  23. if (isSquare(i)){
  24. count++;
  25. }
  26. }
  27. cout<<n<<" : "<<count<<endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement