SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top