【codeforces】- Petya and Java(给不同的数,判断大小,选择不同数据类型)

【数据集】全球大气空气柱平均甲烷(XCH₄)和一氧化碳(XCO)浓度数据集 TROPOMI/WFMD 全球大气空气柱平均甲烷(XCH₄)和一氧化碳(XCO)浓度数据集 TROPOMI/WFMD 阅读详情

A. Petya and Java
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 to9223372036854775807

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 n can'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 usecout (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.

Examples
input
127
output
byte
input
130
output
short
input
123456789101112131415161718192021222324
output
BigInteger

用字符串把大数单独拿出来判断,其他的就可以直接和临界值比较判断类型。有一点,是负数是要注意位数

#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]!='-')  
        {  
            if (l>19)
				printf("BigInteger\n");  
            else if(l==19)  
            {  
                int t=strcmp(a,"9223372036854775807");  
                if(t==-1||t==0)  
                    printf("long\n");  
                else  
                    printf("BigInteger\n");  
            }  
			else if(l>=11&&l<19)  
                printf("long\n");  
            else  
            {  
                __int64 n=a[0]-'0';  
                for (int i=1;i<l;i++)  
                    n=n*10+(a[i]-'0');  
                if (n>=0&&n<=127)  
                    printf("byte\n");  
                else if(n>=128&&n<=32767)  
                    printf("short\n");  
                else if(n>=32768&&n<=2147483647)  
                    printf("int\n");  
                else  
                    printf("long\n");  
            }  
        }  
        else  
        {  
        	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 n=a[1]-'0';  
                for(int i=2;i<=l;i++)  
                    n=n*10+(a[i]-'0');  
                if(n>=0&&n<=128)  
                    printf("byte\n");  
                else if(n>=129&&n<=32768)  
                    printf("short\n");  
                else if(n>=32769&&n<=2147483648)  
                    printf("int\n");  
                else 
                    printf("long\n");  
            }  
    	}
    }  
    return 0;  
}  








uniapp(全端兼容) - 最新详细实现双色球开奖走势图功能组件,uni-app红球走势图/蓝球走势图,解决双色球 “蓝球连线“ 问题,双色球效果及用线连接每个号码详细教程(同样适用于彩票开奖走势图 uni-app,双色球,安卓app,苹果app,微信小程序,移动端,H5网页,手机网站,微信小程序、支付宝小程序,手机app端,nvue,红球走势,蓝球走势,连线,uniapp(vue):js实现双色球开奖走势图带连线,vue2,vue3,uniApp双色球组件插件,uniapp如何实现双色球走势图和连线,彩票走势图,前端 Vue实现彩票走势图,详细示例,走势图,彩票项目,绘制股票走势图,前端 JS实现彩票开奖走势图 连线,Uniapp有没有双色球的页面代码,红球蓝球的走势图如何做,双色球红球和值尾走势图, 阅读详情

相关推荐

MOSFET导通电阻Rdson全解析:物理组成、公式推导与工程选型要点

在功率电子设计中,MOSFET作为核心开关器件,其导通电阻Rdson直接决定导通损耗与系统效率。从半导体物理角度看,Rdson并非单一固定值,而是由源极电阻、沟道电阻、累积层电阻、JFET区电阻、漂移区电阻及衬底电阻等多个分量串联而成,并随栅极驱动电压、结温以及击穿电压等级发生显著变化。理解Rdson的物理来源与数学表达,有助于工程师在低压大电流与高压小电流等不同场景中合理选型、优化驱动电压并准确估算热损耗。文章从沟道电阻公式出发,深入剖析耐压与导通电阻的物理矛盾、温度系数的影响规律,并给出数据手册参数的正

weixin_29163857的博客 224

A. Petya and Java

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.

无知的我 1955

弱电网下整流器阻抗重塑技术及Simulink实现

电力电子系统中,阻抗匹配是确保稳定运行的核心原理。当整流器在弱电网环境下工作时,电网阻抗变化会导致系统谐振,传统被动阻尼方案往往难以应对。阻抗重塑技术通过有源控制策略动态调整系统等效阻抗,其技术价值在于实现高效稳定的能量转换。该技术在新能源发电、工业变频器等场景有广泛应用。本文结合Simulink仿真平台,详细解析有源阻尼和陷波器两种阻抗重塑策略的实现方法,其中涉及的关键技术点包括Middlebrook稳定性判据和DSP算法实现时序优化。通过合理的参数整定和工况测试,工程师可以有效解决弱电网条件下的整流器振

weixin_29164185的博客 254

【CodeForces】[66A]Petya and Java

判断一个数的数据类型除了BigInteger之外其它的都可以直接判断 所以主要是判断是否是BigInteger 可根据位数 那么只需要判断位数与边界值位数相同的情况 其余的就是一些小技巧了

BoilTask Talk Show 695

别再到处找离线包了!Visual Studio 2022 企业版/社区版离线安装保姆级教程(含工作负载选择指南)

本文提供Visual Studio 2022企业版/社区版离线安装的详细教程,包括工作负载选择指南和批量安装优化策略。针对网络隔离或带宽受限环境,介绍如何制作离线安装包、选择合适的工作负载组合,并分享高级技巧如增量更新和自动化部署,帮助团队高效统一开发环境配置。

weixin_28745821的博客 754

单细胞测序流程(八)单细胞的marker基因转化和​GO富集分析

系列文章目录 单细胞测序流程(一)简介与数据下载 单细胞测序流程(二)数据整理 单细胞测序流程(三)质控和数据过滤——Seurat包分析,小提琴图和基因离差散点图 单细胞测序流程(四)主成分分析——PCA 单细胞测序流程(五)t-sne聚类分析和寻找marker基因 单细胞测序流程(六)单细胞的细胞类型的注释 单细胞测序流程(七)单细胞的细胞类型轨迹分析———————————————— 本期主讲内容——单细胞的maeker基因转化和​富集分析 marker基因转化是为了将基因的id和基.

qq_45478665的博客 1万+

CodeForces 66A - Petya and Java(思维)

A. Petya and Java time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Little Petya has recently started attending a programming club. Naturall

Snakeflute的博客 576

SpyGlass Lint脚本实战:从环境配置到报告生成的完整流程解析

本文详细解析了使用SpyGlass Lint脚本进行数字芯片设计代码质量检查的完整自动化流程。从环境配置、目录结构设计,到核心TCL脚本的编写与模块化配置,再到脚本执行、调试技巧及报告解读,提供了构建健壮、可维护自动化检查框架的实战指南。文章重点阐述了如何通过脚本实现从环境配置到报告生成的一键式操作,并探讨了与企业级CI/CD流程集成的进阶方案。

weixin_29196613的博客 445

CodeForce 66A Petya and Java

A - Petya and Java Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Little Petya has recently started attending a programming clu

Calm微笑 580

【2026最新版】python点云处理算法汇总(长期更新版)

python点云处理算法整理。博客长期更新,最近一次更新时间为:2026年10月4日。

点云侠的博客 42万+

修复Oracle MySQL Server 安全漏洞(CVE-2023-0464)

修复Oracle MySQL Server 安全漏洞(CVE-2023-0464)

路~可以走过 3692

Petya and Java strcmp的使用

Petya and Java Time Limit: 2000MS Memory Limit: 262144K 64bit IO Format: %I64d & %I64u Description Little Petya has recently started attending a programming club. Naturally he is facing

wwk0125的专栏 569

AgentScope Java 2.0 项目实战:教你完整搭建企业级多租户AI数据分析Agent平台

本文详细讲解如何从零开始构建一个企业级多租户AI数据分析Agent平台(agentscope-dataagent)。涵盖项目的环境准备、项目骨架搭建、后端15个核心模块开发(认证授权、Agent网关、会话管理、SSE流式聊天、能力市场、Webhook通道、Docker沙箱等)、前端完整开发(路由守卫、SSE流式读取、28个页面组件)、内置资源定义、构建打包、测试验证及单机/Docker/分布式部署全流程。

program哲学 617

(判断数字类型)C - Petya and Java CodeForces - 66A

C - Petya and Java CodeForces - 66A Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he ...

tomjobs的博客 518

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

CodeForces Petya and Java strcmp的使用

B - Petya and JavaTime Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u DescriptionLittle Petya has recently started attending a programming club. Naturally he is facing t...

weixin_30470857的博客 67

CodeForces 66A Petya and Java

A. Petya and Java time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya has recently started attendi

A_ice 593

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

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 cl

wyg1997 924

Codeforces 66A:Petya and Java(水题)

A. Petya and Java time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya has recently started attendi

zugofn的博客 441

Codeforces刷题之路——112A Petya and Strings

A. Petya and Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya loves presents. His mum b

莫欺少年穷 1131

String Task CodeForces - 118A

String Task CodeForces - 118A Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string...

Ich/liebe/dich的编程せかい 289

CodeForces - 118A String Task 【水题】

** CodeForces - 118A String Task 【水题】 ** Problem Description Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the...

weixin_43337555的博客 279

Petya and Java(整型类型)

Petya and Java Time Limit:2000MS    Memory Limit:262144KB     64bit IO Format:%I64d& %I64u Submit Status Description Little Petya has recently started attending a programming club. Naturally

昨日明眸 599

CFPetya and Exam(暴力)

#include #include #include #include #include using namespace std; const int MAX=1e5+10; char query[MAX]; char good[MAX]; char str[MAX]; int n; int vis[MAX]; int flag; int main() { while(scanf("%s",

NicoleYWJ的博客 461

Petya and Java strcmp的使用

B - Petya and Java Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description Little Petya has recently started attending a programming club. Na

qq_34472846的博客 649

Codeforces 18D Seller Bob java大数+贪心

题目链接:点击打开链接 java: import java.math.BigInteger; import java.util.Scanner; public class Main { static int N = 5005; static BigInteger[] er = new BigInteger[N]; static BigInteger E = new BigInteger

九野的博客 1730

Codeforces gym101933 I 大数(Java&C++) 超递增背包

I. Intergalactic Bidding time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Today the Intergalactic Council of Pebble Coins (ICPC) conducted an...

OtterVのrecorder 580

acm 2016/5/18 hpu15级练习 A

A - Petya and Java Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 66A Description Little Petya has recently started att

R 363

A. Petya and Strings

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Petya loves presents. His mum bought him two strings of t

无知的我 2433
上一篇: 【codeforces】-#351A--Bear and Game(第一次cf,错到哭,还是有点开心的,嘿嘿)
下一篇: 【codeforces】-- Life Without Zeros(两个数先加后消去包含的零和先消后加判断是否相等 )
Bear1997
博客等级 码龄11年 55粉丝 369原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值