0% found this document useful (0 votes)
23 views1 page

#Include #Include Using Namespace STD

The provided C++ code checks if a given integer 'n' can be expressed in a specific mathematical form involving two variables 'i' and 'j'. It iterates through possible values of 'i' and 'j' up to the square root of 'n', and prints 'YES' if a valid combination is found, otherwise it prints 'NO'. However, the code has a logical flaw as it does not break out of the outer loop upon finding a solution.

Uploaded by

Da Hood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

#Include #Include Using Namespace STD

The provided C++ code checks if a given integer 'n' can be expressed in a specific mathematical form involving two variables 'i' and 'j'. It iterates through possible values of 'i' and 'j' up to the square root of 'n', and prints 'YES' if a valid combination is found, otherwise it prints 'NO'. However, the code has a logical flaw as it does not break out of the outer loop upon finding a solution.

Uploaded by

Da Hood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <iostream>

#include <bits/stdc++.h>
using namespace std;

int main(){
int n, i, j;
cin >> n;

for(i = 1; i < sqrt(n); i++){


for(j = 1; j < sqrt(n); j++){
if(n == (i+j)*(i*i-i*j+j*j)){
cout << "YES";
break;
}
}
}
cout << "NO";
}

You might also like