Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- bool isSquare(long long n){
- long long squareRootN=(long long)round((sqrt(n)));
- if(squareRootN*squareRootN == n) {
- return true;
- }
- else {
- return false;
- }
- }
- int main(){
- long long n;
- cin>>n;
- int count = 0;
- for (long long i = 1; i<n; i++){
- if (isSquare(i)){
- count++;
- }
- }
- cout<<n<<" : "<<count<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement