Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int countPairs(int N)
- {
- int count = 0;
- for (int i = 1; i <= sqrt(N); i++) {
- int sq = i * i;
- int diff = N - sq;
- int sqrtDiff = sqrt(diff);
- if (sqrtDiff * sqrtDiff == diff)
- count++;
- }
- return count;
- }
- int main()
- {
- countPairs(10);
- return 0;
- }
Add Comment
Please, Sign In to add comment