The calculation of the written code does not end.
What is the problem?
Thank you very much.
A, B, X = map (int, input (). split ()) def N_prices (n): return (A * n + B * (len (str (n)))) if X<= N_prices (0): print ('0') if N_prices (10 ** 9)<= X: print ('109') for i in range (1, 10 ** 9): if N_prices (i)<= X and X<= N_prices (i + 1): print (str (i))
python3.7.3, jupyter notebook
Answer # 1
for i in range (1, 10 ** 9): if N_prices (i)<= X and X<= N_prices (i + 1): print (str (i))
10 ** 9, that is, the above code is repeated 1000 million times, so it will take a lot of time.
Answer # 2
Because I'm trying to calculate 10 ^ 9 times, if it takes 1us to do it once, it's okay to take 1000 seconds.
$python -m timeit '(12345 * 10111213 + 67890 * (len (str (10111213))))' 1000000 loops, best of 3: 0.295 usec per loop
Answer # 3
How about reducing the number of loops to see how long it takes?
for i in range (1, 10 ** 6)
I think that is the limit that can wait.
- python - i don't know the cause of the error
- error when performing numerical calculation with python
- python contour detection¢roid calculation
- python 3x - how to get the value of scrolledtext
- python - delete bom on the command line
- python - what are the frequency axis and time axis in scipysignalstft?
- python - i want to find the mode of a pixel with a pixel value of 1 or more
- python - i want to speed up the calculation of for statements with numpy
- python - i want the block to disappear when the ball hits the block
- html - the contact form is not centered
- python reverse polish notation calculation algorithm
- python - how to delete an apostrophe in the list
- python - the link created with the collected path does not open
- wordpress does not jump to the specified page
- html - i want to apply the: not tag
- how to count days of the week python
- python - i can't get the element with selenium
- python - i want to ignore the header and loop