我的猜测啦
题目应该是要写成函数
import java.util.Scanner;
public class a_8nz2i {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt ();
int s = sss(n);
System.out.println("s=" + s + " n=" + n);
}
private static int sss(int x) {
int tmp = 0;
while(x>0){
tmp+=x;
x/=2;
}
return tmp;
}
}
不过就我通灵出来的结果
题目应该是要找二进制啦
ㄎㄎ
然后我也好久没写 java 了 都在写 Kotlin
fun main(args: Array<String>) {
val n = readLine()!!.toInt()
val s = sss(n)
println("s=$s n=$n")
}
private fun sss(xx: Int): Int {
var x = xx
var tmp = 0
while (x > 0) {
tmp += x
x /= 2
}
return tmp
}
我积积..阴阴德..了
求老司机载我上车 > < 1000p