trouble with algorithm
- by rebel_UA
David likes number of estimates with base "k" and not a multiple(a%2!=0) of the number of zeros at the end.
Set system and the number of the order and print it
I need to optimi this algoritm:
class David{
private:
int k;
public:
David();
David(int);
int operator[] (int);
};
David::David(){
k=10;
};
David::David(int k){
this->k=k;
}
int David::operator[] (int n){
int q;
int p;
int i=1;
for(int r=0;r<n;i++){
q=0;
p=i;
for(;;){
if(p%k)
break;
if(p==0)
break;
++q;
p/=k;
}
if(q%2){
r++;
}
}
return i-1;
}