986D. Perfect Encoding
fft, math, 3100, https://codeforces.com/problemset/problem/986/D You are working as an analyst in a company working on a new system for big data storage. This system will store n different objects. Each object should have a unique ID.
To create the system, you choose the parameters of the system — integers m≥1 and
Developers say that production costs are proportional to
Input
In the only line of input there is one positive integer n. The length of the decimal representation of n is no greater than
Output
Print one number — minimal value of
12345678901234567890123456789Output
177【马铉钦25化院】由于python的强大的内置的大整数处理能力,这绝对是最水最水的3100,感觉做的体感难度也就在1500左右。 考虑应该把
import sys
from math import log,ceil
sys.set_int_max_str_digits(1800000)
n=int(input())
li=[0,1,2,3,4,5,5,6,6,6,7,7,7,8,8,8,8,8,8]
if n<=18:
print(li[n])
exit()
a=log(2,3)
b=log(n,3)
c=int(b-a-1)
d=round(pow(3,b-c))
if d*3**c<n:#由于浮点数精度的问题,需要重新判断一下
print(li[d+1]+3*c)
else:
print(li[d]+3*c)