Created
December 26, 2019 05:47
-
-
Save Rubix982/587f00a48a2001267c6cd1b07642b636 to your computer and use it in GitHub Desktop.
Gets back num of digits in O(1) time
This file contains hidden or 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
| #include "stdc++.h" | |
| using namespace std; | |
| // Gives back the number of digits in O(1) time | |
| int main(void) { | |
| std::cout << "<------- START ------->" << "\n"; | |
| for (int i = 1; i <= 50000; ++i) std::cout << (int) floor( 1 + log10( (double) i ) ) << " " << i << "\n"; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment