Created
June 26, 2016 14:57
-
-
Save joaogui1/d6837bae81700adb736951c12746cf72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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