Home>
Question
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))
Environment
python3.7.3, jupyter notebook

Answer # 1

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.
Easy estimation.
$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.
Related articles
 multiple classification score calculation errors, python, svm
 python  sum the elements in another list
 file reading and calculation using python
 python  graph is not drawn
 python  normalization does not work
 python 3x  i'm not sure how to index pandas df
 python  i did timetime () but the time is not measured
 python  find the minimum value in list
 python  i want to calculate matrix calculation with numpy for statement with numpydot
 python  how to use the pytest mock
 python  about batch calculation of pandas data frame
 python  return does not return a value
 python 3x  replace does not change
 python  i want the game to work properly
 python  i can't express the structure of json well
 python  i want to hold the dataframe vertically
 python  save the file name as a variable
 python polygon area calculation can't assign to operator
 i want to automatically generate a calculation problem in python
 python 3x  i want the if statement to work
Related questions
 python  regression analysis with statsmodels cannot resolve the error that it contains infinity or nan
 python  jupyter notebook doesn't work with vs code
 about auxiliary lines and axis scales of python heatmap
 python scraping jsonloads () jsondecodeerror
 python  about seabornhistplot
 python  failed to import tensorflow in jupyter notebook
 getoldtweetserror solution for python
 python  janome analyzer error
 python  i want to import a csv file locally
 python  docker environment construction error
10 ** 9, that is, the above code is repeated 1000 million times, so it will take a lot of time.