You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] how to count number of digits in O(1)?

I want to count number of digits in O(1) And how is it possible?

asked 23 Sep '17, 23:40

pandey_96's gravatar image

1★pandey_96
667
accept rate: 0%

closed 04 Oct '17, 21:21

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066

The question has been closed for the following reason "Issue Resolved." by vijju123 04 Oct '17, 21:21


convert the integer to String (rather take the input as String) .. length of the string is the number of digits in the NUMBER.

link

answered 23 Sep '17, 23:46

mayukh45's gravatar image

5★mayukh45
213
accept rate: 0%

Bro , you could easily get these things in one google search

Anyway the answer is log10(n)+1

link

answered 04 Oct '17, 17:28

spp____'s gravatar image

2★spp____
1.1k211
accept rate: 9%

This may help

https://stackoverflow.com/questions/10723295/counting-number-of-digits-in-a-number-in-o1

More over you can do this while taking input simultaneously when using fast input methods like getchar() .

link

answered 23 Sep '17, 23:48

trashmaster's gravatar image

2★trashmaster
98619
accept rate: 12%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×4

question asked: 23 Sep '17, 23:40

question was seen: 305 times

last updated: 04 Oct '17, 21:21