CodeForces 66A - Petya and Java(思维)

CodeForces 357C - Knight Tournament(模拟) C. Knight Tournament time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Hooray! Berl II, the king of Berland is making a knight tournament. T 阅读详情

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. 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 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 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.

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

题意:
看这个数的数据类型(都是整树,且为正数)。

解题思路:
首先判断长度。
当长度和极值的长度相同时,在用strcmp判断。

AC代码:

#include<bits/stdc++.h>
using namespace std;
char s[105];
int main()
{
    gets(s);
    int len = strlen(s);
    if(len < 3 || len == 3 && strcmp("127",s) >= 0)
    {
        printf("byte");
    }
    else
    {
        if(len < 5 || len == 5 && strcmp("32767",s) >= 0)
        {
            printf("short");
        }
        else
        {
            if(len < 10 || len == 10 && strcmp("2147483647",s) >= 0)
            {
                printf("int");
            }
            else
            {
                if(len < 19 || len == 19 && strcmp("9223372036854775807",s) >= 0)
                {
                    printf("long");
                }
                else
                {
                    printf("BigInteger");
                }
            }
        }
    }
    return 0;
}
SAP LTMC实战指南:物料主数据高效导入全解析 本文详细解析了SAP LTMC工具在物料主数据高效导入中的实战应用,包括工具选择、项目搭建、模板定制、数据导入全流程及常见问题解决方案。重点介绍了LTMC的预置模板、LTMOM灵活配置、数据校验机制等核心功能,帮助用户快速掌握SAP数据迁移技巧,提升工作效率。 阅读详情

相关推荐

FairyGUI编辑器自定义菜单扩展插件

本文涉及到的软件有:FairyGUI,VSCode代码环境涉及到了:LuaVSCode插件:EmmyLua在编写FairyGUI编辑器菜单前,了解一下FairyGUIEditor的API会有效的帮助我们解决很多问题。FairyGUI的扩展是通过编辑器自带的插件功能实现的,插件中我使用的是lua环境模板。导入编辑器的LuaAPI,文件可以在FairyGUI-Editor源码的插件目录中找到。接下来将通过功能来说明对应的API作用。

Aili_Xiao的博客 4505

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

WRF-BEM相关参数说明

本参数适用于WRF-BEM模拟武汉市气候。

m0_60013472的博客 1903

【CodeForces】[66A]Petya and Java

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

BoilTask Talk Show 695

基于IDEA与Mill构建Windows下的Chisel开发环境——香山处理器源码解析实战

本文详细指导如何在Windows系统下使用IDEA集成开发环境和Mill构建工具搭建Chisel开发环境,并以香山处理器源码为实战案例进行解析。内容涵盖环境准备、源码获取、工程构建、IDEA配置优化及代码阅读技巧,帮助开发者高效学习硬件设计语言。

a1b2c3d的博客 722

Python爬虫实战:如何优雅地处理BOSS直聘的反爬机制与Cookie失效问题

本文详细介绍了如何通过Python爬虫技术优雅应对BOSS直聘的反爬机制与Cookie失效问题。从多账号轮换、动态请求头生成到代理IP管理,提供了一套完整的解决方案,帮助开发者构建稳定高效的数据采集系统,有效提升爬虫成功率与数据质量。

weixin_30733003的博客 1573

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

Win7/10/11文件拖拽导致资源管理器闪退问题

最近老是遇到把文件从资源管理器拖动到微信或者浏览器时,资源管理器直接闪退的问题,一开始在公司遇到了还以为是电脑配置太低,直到被封闭在家办公,发现自己的高级电脑也有这个问题,那就来了解了解问题是出在什么地方把。

Nicer_feng's blog 1万+

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

Python 神经计算实训 实训答案分享

【代码】Python 神经计算实训 实训答案分享。

2403_89314916的博客 364

vue+ThreeJS:从0 到1 搭建开发环境

本系列教程是在vue2.X的基础上加载threeJS程序,来开发各种示例程序。

大剑师兰特的GIS世界 2353

(判断数字类型)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

图机器学习(2)——图的可视化

图结构可通过图形化方式直观呈现。节点通常用圆形表示,边则用连接线表示。然而当节点和边数量增加时,绘制清晰的图形表示可能会变得相当困难,这主要源于节点在二维坐标系中的布局问题。对于包含数百个节点的图,手动指定每个节点的坐标显然不切实际。在本节中,我们将介绍如何在不指定每个节点坐标的情况下绘制图形。我们将利用两种不同的解决方案:networkx 和 Gephi。

盼小辉丶的博客 9148

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

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

Choosing a Programming Language for Windows Mobile Development

Choosing a Programming Language for Windows Mobile Development 8/28/2008 There are several approaches which can be taken when developing applications for Windows Mobile powered devices. In this

小皮的专栏 1136

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

B. Coins

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In Berland a money reform is being prepared. New coins are being

无知的我 1882

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

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

Codeforces 66A Petya and Java

Petya and Java 题意:五种数据类型,每种类型能存储的数据范围不同,占据的字节数也不同,求存储n可用的最少字节的数据类型。 思路:以字符串形式表示n,用函数strcmp进行比较。 #include #include #include using namespace std; int main(){ char a[105]; int len; scanf("%s",a);

渣渣眼里没有水题 465

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

Codeforces 548C - Mike and Frog(暴力循环节)

C. Mike and Frog time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Mike has a frog and a flower. His frog is named Xaniar and his flower is n

Snakeflute的博客 932

Codeforces 363D - Renting Bikes(贪心二分)

D. Renting Bikes time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output A group of n schoolboys decided to ride bikes. As nobody of them has a bik

Snakeflute的博客 869

Codeforces 604C - Alternative Thinking(思维)

C. Alternative Thinking time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Kevin has just recevied his disappointing results on the USA Ident

Snakeflute的博客 802

Codeforces 544B - Sea and Islands(构造)

B. Sea and Islands time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output A map of some object is a rectangular field consisting of n rows and n c

Snakeflute的博客 788

CodeForces 584D - Dima and Lisa(数论)

D. Dima and Lisa time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Dima loves representing an odd number as the sum of multiple primes, and L

Snakeflute的博客 694
上一篇: CodeForces 731A - Night at the Museum(模拟)
下一篇: CodeForces 66B - Petya and Countryside(水题)
Snakeflute
博客等级 码龄11年 14粉丝 172原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值