样例输入
7
样例输出
3
解析
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
* 解析
* 结果应该是最少的砝码数量
首先,如果要称的重量为1的话,只能选择重量为1的砝码,1是必选的一个砝码。
然后再称比1重的,反正都是要再加砝码,那我们为何不选一个能称的重量尽可能大的呢。
选1、2的砝码可以满足1=1,2=2,1+2=3
选1、3的砝码可以满足1=1,2=3-1,3=3,4=3+1
选1、4的砝码可以满足1=1,2=?无法称2,不合题意
因此我们选择的砝码组合是1、3,此时我们可以称的最大重量为4
当我们还需要再增加砝码时
同理可得
选1、3、9的组合可以满足小于等于13(13=1+3+9)的所有重量
转自https://blog.csdn.net/Striver00/article/details/116031667
* 比如说我定义的砝码是1 3 9 3n
* 1砝码的最大重量值 1
* 2砝码的最大重量值 4
* 3 13
*/
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
least(scan.nextLong());
scan.close();
}
public static void least(long value) {
long result = 1l;
long total = 1l;
long weight = 1;
while(total < value) {
result++;
weight = weight*3;
total += weight;
}
System.out.println(result);
}
}
n = int(input())
w = 1
count = 1
t = 1
while n>t:
count += 1
w = w*3
t += w
print(count)