Skip to content

Instantly share code, notes, and snippets.

@Rubix982
Created December 26, 2019 05:47
Show Gist options
  • Select an option

  • Save Rubix982/587f00a48a2001267c6cd1b07642b636 to your computer and use it in GitHub Desktop.

Select an option

Save Rubix982/587f00a48a2001267c6cd1b07642b636 to your computer and use it in GitHub Desktop.
Gets back num of digits in O(1) time
#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