Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BigNumber raiz(BigNumber n)
- {
- int cantDigitos = (n.size()+1)/2;
- string r = "1"+string(cantDigitos-1, '0');
- BigNumber res = r, aux("0");
- for(int i=0; i<cantDigitos; i++)
- {
- for(int j=(i ? '0' : '1'); j<='9'; j++)
- {
- r[i] = j;
- aux = r;
- if(aux*aux <= n)
- {
- res = aux;
- }
- else
- {
- r[i]--;
- break;
- }
- }
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment