Algorithm
Problem Statement for ProperDivisors Problem link- https://community.topcoder.com/stat?c=problem_statement&pm=8547&rd=11128 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
class ProperDivisors {
public:
int analyzeInterval(int a, int b, int n) {
int e = a + b;
long long p, res = 0;
bool ok;
for(int i = 1; i <= e; ++i) {
for(int j = i * 2; j <= e; j += i) {
p = 1;
ok = true;
for(int k = 0; k < n; ++k) {
p *= i;
if(p > j) {
ok = false;
break;
}
}
if(ok && j % p == 0)
continue;
if(j >= a && j <= e)
++res;
}
}
return res;
}
};
Copy The Code &
Try With Live Editor
Input
32
1
3
1
3
Output
5
Demonstration
TopCoder Solution SRM394-D2-1000 Statement for ProperDivisors C,C++, Java, Js and Python ,SRM394-D2-1000,TopCoder Solution