备战蓝桥之思维

补充2024.3.27的题目,忘提交了

12.子树的大小 - 蓝桥云课 (lanqiao.cn)



import java.awt.Checkbox;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.math.MathContext;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.print.attribute.standard.JobMessageFromOperator;
import javax.print.attribute.standard.ReferenceUriSchemesSupported;

import java.awt.Checkbox;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.math.MathContext;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.print.attribute.standard.JobMessageFromOperator;
public class Main {	
public static void main(String[] args) throws IOException {
	Scanner sc=new Scanner(System.in);
	BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw1=new PrintWriter(System.out);
	String[] aStrings=br1.readLine().split(" ");
  aa=Integer.parseInt(aStrings[0]);
  while(aa>0) {
	  aa--;
	  String[] bStrings=br1.readLine().split(" ");
	  long a=Long.parseLong(bStrings[0]);//Integer.parseInt(bStrings[0]);
	  long b=Long.parseLong(bStrings[1]);//Integer.parseInt(bStrings[1]);
	  long c=Long.parseLong(bStrings[2]);//Integer.parseInt(bStrings[2]);
	  long answer=1;
	  long biaozhi=0;
	  long left,right;
	  left=right=c;
	  while(true) {
		 if(biaozhi==1) {
			 break;
		 }
		 left=(left-1)*b+2;
		 right=right*b+1;
		 if(left>a) {
			 break;
		 }
		 if(right>=a) {
			 right=a;
			 biaozhi=1;
		 }
		 answer=answer+right-left+1;
	  }
	pw1.println(answer);
  }
pw1.flush();
pw1.close();
}
public static int aa;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值