Skip to content

Instantly share code, notes, and snippets.

@joaogui1
Created June 26, 2016 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaogui1/d6837bae81700adb736951c12746cf72 to your computer and use it in GitHub Desktop.
Save joaogui1/d6837bae81700adb736951c12746cf72 to your computer and use it in GitHub Desktop.
//busca nos dígitos binários do número
//não é uma busca binária
//imprime a parte inteira da raiz de n
int n, sq = 0, test;
cin >> n;
for(int pot = 31; pot >= 0; --pot){
test = sq + (1 << test);
if(test*test <= n) sq = test;
}
cout << sq << "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment