I forcibly broke through, so I will keep a record of it.
Since the problem statement is long, please use here.
TorT.java
import java.util.Scanner;
public class TorT{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int count = 0;
for(int i = 0; i < N; i++){
int a = sc.nextInt();
while(true){
if(a % 2 == 0){
a = a / 2;
count = count + 1;
}else{
break;
}
}
}
System.out.println(count);
}
}
If the variable a is an even number, you can rotate the for statement until it is divisible by 2 and count the number of times. If it is an odd number, break it and exit the for statement. The event of "multiplying 3" has nothing to do with "dividable by 2", so I think it's best to ignore it.
$ java TorT
> 10
>2184
>2126
>1721
>1800
>1024
>2528
>3360
>1945
>1280
>1776
39
I was able to answer all the test cases with "AC".
Recommended Posts