首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【Codeforces】66A - Petya and Java(模拟)

【Codeforces】66A - Petya and Java(模拟)

作者头像
FishWang
发布2025-08-26 15:52:19
发布2025-08-26 15:52:19
8700
代码可运行
举报
运行总次数:0
代码可运行

time limit per test 

2 seconds

memory limit per test 

256 megabytes

input 

standard input

output 

standard output

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 "byte, short, int, long, BigInteger", that can store the natural number n, in accordance with the data given above.

Sample test(s)

input

代码语言:javascript
代码运行次数:0
运行
复制
127

output

代码语言:javascript
代码运行次数:0
运行
复制
byte

input

代码语言:javascript
代码运行次数:0
运行
复制
130

output

代码语言:javascript
代码运行次数:0
运行
复制
short

input

代码语言:javascript
代码运行次数:0
运行
复制
123456789101112131415161718192021222324

output

代码语言:javascript
代码运行次数:0
运行
复制
BigInteger

BigInteger用位数卡一下,其他的比较出来即可。

代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	char a[111];
	int l;
	while (~scanf ("%s",a))
	{
		l = strlen (a);
		if (a[0] == '-')
		{
			l--;
			if (l > 19)
				printf ("BigInteger\n");
			else if (l >= 11 && l < 19)
				printf ("long\n");
			else if (l == 19)
			{
				int t = strcmp (a,"-9223372036854775808");
				if (t == -1 || t == 0)
					printf ("long\n");
				else
					printf ("BigInteger\n");
			}
			else
			{
				__int64 num = a[1] - '0';
				for (int i = 2 ; i <= l ; i++)
					num = num * 10 + (a[i] - '0');
				if (num >= 0 && num <= 128)
					printf ("byte\n");
				else if (num >= 129 && num <= 32768)
					printf ("short\n");
				else if (num >= 32769 && num <= 2147483648)
					printf ("int\n");
				else
					printf ("long\n");
			}
		}
		else
		{
			if (l > 19)
				printf ("BigInteger\n");
			else if (l >= 11 && l < 19)
				printf ("long\n");
			else if (l == 19)
			{
				int t = strcmp (a,"9223372036854775807");
				if (t == -1 || t == 0)
					printf ("long\n");
				else
					printf ("BigInteger\n");
			}
			else
			{
				__int64 num = a[0] - '0';
				for (int i = 1 ; i < l ; i++)
					num = num * 10 + (a[i] - '0');
				if (num >= 0 && num <= 127)
					printf ("byte\n");
				else if (num >= 128 && num <= 32767)
					printf ("short\n");
				else if (num >= 32768 && num <= 2147483647)
					printf ("int\n");
				else
					printf ("long\n");
			}
		}
	}
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-08-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档