import java.util.Scanner;
import java.util.Arrays;
public class Main {
private static Scanner cin;
private static int[] rem = new int[501];
public static void main(String args[]) throws Exception {
cin = new Scanner(System.in);
Arrays.fill(rem,-1);
int n = cin.nextInt();
System.out.println(calc(n/2)+1);
}
private static int calc(int step) {
int ret = 0;
if(-1 != rem[step]) {
return rem[step];
}
if(step>=1) {
for(int i=1;i<=step;i++) {
if(-1 != rem[i]) {
ret = ret + rem[i]+1;
}else {
ret = ret + calc(i/2)+1;
rem[i] = ret;
}
}
}
return ret;
}
}
Java实现 洛谷 P1028 数的计算
程序员文章站
2022-07-13 11:59:03
...
上一篇: Redis 的基础命令集合
下一篇: dp,洛谷p1028 数的计算