全部评论
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t > 0) {
int a = sc.nextInt();
int b = sc.nextInt();
int p = sc.nextInt();
int q = sc.nextInt();
int total = 0;
while (a < b) {
if (a + p >= b) {
a = a + p;
} else {
p *= q;
}
total++;
}
System.out.println(total);
}
sc.close();
}
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int[] arr = new int[4];
for(int i=0; i<n;i++){
for(int j=0; j<4; j++){
arr[j] = input.nextInt();
}
cal(arr);
}
}
public static void cal(int[] arr){
int A = arr[0];
int B = arr[1];
int p = arr[2];
int q = arr[3];
if(B <= A){
System.out.println(0);
}else {
int count = 0;
while(B > A+p){
if( (A + p) > (A + p * q)){
A = A + p;
}else{
p = p * q;
}
count++;
}
System.out.println(++count);
}
}
} 第二题ac代码
我太难受了,今天下午体测到四点半,去了半条命,测完跑回实验室就开始做,难受
相关推荐
11-29 16:20
广东白云学院 数据运营 点赞 评论 收藏
分享