CodeForces66APetya and Java

Description

Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.

But having attended several classes of the club, Petya realized that not all tasks require using the BigInteger type. It turned out that in some tasks it is much easier to use small data types. That's why a question arises: "Which integer type to use if one wants to store a positive integer n?"

Petya knows only 5 integer types:

1) byte occupies 1 byte and allows you to store numbers from  - 128 to 127

2) short occupies 2 bytes and allows you to store numbers from  - 32768 to 32767

3) int occupies 4 bytes and allows you to store numbers from  - 2147483648 to 2147483647

4) long occupies 8 bytes and allows you to store numbers from  - 9223372036854775808 to 9223372036854775807

5) BigInteger can store any integer number, but at that it is not a primitive type, and operations with it are much slower.

For all the types given above the boundary values are included in the value range.

From this list, Petya wants to choose the smallest type that can store a positive integer n. Since BigInteger works much slower, Peter regards it last. Help him.

Input

The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number ncan't be represented as an empty string.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Output

Print the first type from the list "byteshortintlongBigInteger", that can store the natural number n, in accordance with the data given above.

Sample Input

Input
127
Output
byte
Input
130
Output
short
Input
123456789101112131415161718192021222324
Output
BigInteger
 
      
代码:
#include<iostream>
#include<algorithm>
#include<string.h>
int main()
{
	__int64 i,k;
	char n[10000],l;
	char a[4]="127",a1[5]="-128";
	char b[6]="32767",b1[7]="-32768";
	char c[11]="2147483647",c1[12]="-2147483648";
	char d[20]="9223372036854775807",d1[21]="-9223372036854775808";
	while(scanf("%s",n)!=EOF)
	{
		k=strlen(n);
		if(n[0]=='-')
		{
			if(k<4||k==4&&(strcmp(n,a1)<=0))
			printf("byte\n");
			else if(k<6||k==6&&(strcmp(n,b1)<=0))
			printf("short\n");
			else if(k<11||k==11&&(strcmp(n,c1)<=0))
			printf("int\n");
			else if(k<20||k==20&&(strcmp(n,d1)<=0))
			printf("long\n");
			else
			printf("BigInteger\n");
		}
		else
		{
			if(k<3||k==3&&(strcmp(n,a)<=0))
			printf("byte\n");
			else if(k<5||k==5&&(strcmp(n,b)<=0))
			printf("short\n");
			else if(k<10||k==10&&(strcmp(n,c)<=0))
			printf("int\n");
			else if(k<19||k==19&&(strcmp(n,d)<=0))
			printf("long\n");
			else
			printf("BigInteger\n");
		}
	}
	return 0;
}

思路:这道题我晕,知道用strcmp函数比较字符大小,可是不知道只能比较相同位数的字符,哭死,为此wa了多少次。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值