题意:
思路:
模拟,数太大了可以用java或py写,记录一下大数的输入和A P I
代码:
n.compareTo表示和某个数比较
B i g I n t e g e r . v a l u e O f表示将某个数转为大数
n e w B i g I n t e g e r ( " − 9223372036854775808 " )表示将字符串变为大数
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger n=sc.nextBigInteger(); if(n.compareTo(BigInteger.valueOf(-128))>=0&&n.compareTo(BigInteger.valueOf(127))<=0) System.out.println("byte"); else if(n.compareTo(BigInteger.valueOf(-32768))>=0&&n.compareTo(BigInteger.valueOf(32767))<=0) System.out.println("short"); else if(n.compareTo(BigInteger.valueOf(-2147483648))>=0&&n.compareTo(BigInteger.valueOf(2147483647))<=0) System.out.println("int"); else if(n.compareTo(new BigInteger("-9223372036854775808"))>=0&&n.compareTo(new BigInteger("9223372036854775807"))<=0) System.out.println("long"); else System.out.println("BigInteger"); } }
n=int(input()) if -128<=n<=127: print("byte") elif -32768<=n<=32767: print("short") elif -2147483648<=n<=2147483647: print("int") elif -9223372036854775808<=n<=9223372036854775807: print("long") else: print("BigInteger")