【水String】#61 A. Petya and Java

Java 红包算法、限定最小和最大临界值 package com.cdjj.test; public class Demo { public static void main(String[] args) { randomPackage(); } public static void randomPackage() { double total_money=2; int total_people=20; doubl 阅读详情

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 integern?"

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 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
127
output
byte
input
130
output
short
input
123456789101112131415161718192021222324
output
BigInteger

很明显没有一个数据类型能存这么大的数字,但是我们可以存这么长的字符串

string读入,然后预设置好每两种的界限,string类的大小于符号判断是字典序,所以正好可以判断,那么,直接if/else看就可以了


#include <cstdio>
#include <string>
#include <cstring> 
#include <iostream>
using namespace std;

int main()
{
	char now;
	string s;
	string _byte="127";
	string _short="32767";
	string _int="2147483647";
	string _long="9223372036854775807";
	long long n=0;
	cin>>s;
	int len=s.length();
		 if(len<3	||	(len==3 && s<=_byte))	cout<<"byte";
	else if(len<5	||	(len==5 && s<=_short))	cout<<"short";
	else if(len<10	||	(len==10 && s<=_int))	cout<<"int";
	else if(len<19	||	(len==19 && s<=_long))	cout<<"long";
	else cout<<"BigInteger";
	return 0;
}




移动开发(一):使用.NET MAUI开发第一个安卓APP 它是.NET 多平台应用 UI (.NET MAUI) 是一个跨平台框架,用于使用 C# 和 XAML 创建本机移动和桌面应用。使用 .NET MAUI,可从单个共享代码库开发可在 Android、iOS、macOS 和 Windows 上运行的应用。.NET MAUI 是一款开放源代码应用,是 Xamarin.Forms 的进化版,从移动场景扩展到了桌面场景,并从头重新生成了 UI 控件,以提高性能和可扩展性。 阅读详情

相关推荐

RTKLIB PPP与RTK_POST精密定位实战:从实时到事后处理的完整流程解析

本文详细解析了如何使用RTKLIB进行精密单点定位(PPP)的完整流程,涵盖从实时处理到事后处理(RTK_POST)的关键步骤。文章深入探讨了数据准备、软件配置、核心参数设置(如电离层、对流层、潮汐改正)以及常见问题排查,旨在帮助用户掌握高精度GNSS定位技术,实现从入门到精通的实战应用。

weixin_29047919的博客 290

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

Cocos Creator 2.4 APK逆向实战:如何完整提取游戏资源并还原工程(附工具包)

本文详细介绍了针对Cocos Creator 2.4打包的APK进行逆向工程的完整流程,包括环境搭建、资源索引解析、打包文件提取、图集拆分以及工程结构还原。重点讲解了如何利用config.json和.jsb文件完整提取游戏资源,并生成可被Cocos Creator识别的工程目录与.meta文件,最终实现工程还原的目标。

h3i4j的博客 1508

【CodeForces】[66A]Petya and Java

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

BoilTask Talk Show 695

Graylog日志系统实战:高效接收与解析交换机日志

本文提供Graylog日志系统的实战部署与配置指南,重点讲解如何高效接收与解析交换机日志。通过Docker快速部署,配置Syslog输入,并指导华为、华三等主流交换机将日志发送至Graylog。文章还介绍了使用提取器解析日志字段、创建数据流进行分类,以及设置报警规则,实现从被动排查到主动预警的运维转变,帮助网络工程师构建集中、智能的日志管理系统。

weixin_29284885的博客 545

【全志V821_FoxPi】6-3 GC2083 MIPI摄像头适配

本文介绍了在全志V821芯片上适配GC2083 MIPI摄像头的方案。GC2083是一款支持1080P@30fps的高性能CMOS图像传感器,采用MIPI CSI-2接口,具有低功耗特性。文章详细列出了传感器的技术参数和工作电压要求,并提供了设备树配置示例,包括CSI接口、ISP处理单元和传感器节点的具体设置。通过快速配置命令one_gc2083_sensor或手动修改设备树即可启用该摄像头模组,适用于IPC等对图像质量有要求的嵌入式应用场景。

第四维度的博客 1956

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的博客 575

【一 扣子客户案例合集】【 1.1 抖音电商:通过扣子智能体重塑电商服务新体验】

**摘要:**抖音电商借助扣子(Coze)智能体平台重塑客服体验,通过无代码开发、多模态交互和跨平台发布等功能,解决了传统客服高峰期压力大、成本高及响应机械等痛点。智能体采用直接面客与人工监管结合模式,实现高效精准服务,并通过解构流程、模块化设计优化系统架构。其技术优势包括零配置学习、意图识别、情绪感知等,实际应用中显著提升客服效率300%以上,改善用户体验。未来将进一步拓展至商品推荐、直播互动等场景,推动电商服务智能化升级。

商务合作|问题讨论|交流学习 请联系作者微信,加微信请务必注明来意,博客主页有联系方式 1578

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

智能合约监控告警:提示工程架构师用AI Prompt实现精准预警

当AI大模型(尤其是代码理解模型如CodeLlama、GPT-4 Code)与区块链数据结合,智能合约监控迎来范式革新。AI模型如何精准理解智能合约的业务特殊性?如何避免"AI幻觉"导致的误报?如何让模型学会区分"正常异常"与"攻击前兆"?答案藏在"提示工程"(Prompt Engineering)中。理解特定智能合约的业务逻辑(如DeFi协议的清算机制、NFT的铸造规则)识别复杂的攻击模式(如重入攻击的调用链特征、闪电贷的套利路径)结合链上链下数据进行多维度推理(如关联价格波动与异常交易)

AI架构全栈开发实战笔记 1015

解锁PyCharm+Deepseek:本地部署AI编程超能力

在本次探索中,我们成功地在 PyCharm 中实现了 DeepSeek 的本地化部署,这一过程虽然涉及多个步骤,但每一步都为我们开启 AI 编程大门奠定了基础。从安装最新版 PyCharm,确保我们拥有一个功能强大且兼容性良好的开发环境,到注册 DeepSeek 账号并获取 API Key,这是连接我们与强大 AI 能力的关键纽带。接着,在 PyCharm 中安装 Continue 插件并进行精细配置,让 DeepSeek 能够深度融入我们的编程流程。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 5554

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

【FPGA教程案例87】加解密1——基于FPGA的AES加解密算法verilog实现

DES已走到了它生命的尽头。56比特密钥实在太小,虽然三重DES可以解决密钥长度的问题,但是DES的设计主要针对硬件实现,而今在许多领域,需要用软件方法来实现它,在这种情况下,它的效率相对较低。1997年4月15日美国国家标准和技术研究所(NIST)发起征集AES(Advanced Encryption Standard)算法的活动,并成立了AES工作组。目的是为了确定一个非保密的、公开披露的、全球免费使用的加密算法,用于保护下一世纪政府的敏感信息。这里,我们对AES的基本原理进行介绍:

FPGA/MATLAB学习教程/源码/项目合作开发 2548

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

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

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

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

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

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

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

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 Round #550 (Div. 3) E. Median String 模拟大数运算

题目: You are given two strings s and t, both consisting of exactly k lowercase Latin letters, s is lexicographically less than t . Let's consider list of all strings consisting of exactly k lowerca...

zamaochick的博客 245

codeforces 479A(Expression) Java

暴力虐水题!!!import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import

TinyDolphin的博客 448

Petya and Countryside

Description Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above

WOLF的博客 400

codeforces 111C Petya and Spiders 状态压缩

题目大意:有一个n*m的矩阵,zuiyo

ACMmaxx的专栏 972

(判断数字类型)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
上一篇: 【贪心+读题】Manthan 2011 A. Partial Teacher
下一篇: 【水模拟】#62 A. Irrational problem
糖果天王
博客等级 码龄16年 233粉丝 304原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值