2013 gzhu 校赛
题目描述:
Integer in C++
Problem Description
KIDx: I like Java much more than C++, because I can use BigInteger in Java. :)
However, KIDx has to use C++ language to do a project...
Little KIDx knows 3 integer types in C++:
1) short occupies 2 bytes and allows you to store numbers from -32768 to 32767
2) int occupies 4 bytes and allows you to store numbers from -2147483648 to 2147483647
3) long long occupies 8 bytes and allows you to store numbers from -9223372036854775808 to 9223372036854775807
For all the types given above the boundary values are included in the value range. From this list, KIDx wants you to choose the smallest type that can store a positive integer n.
Input
Each case contains a positive integer n. It consists of at least one digit and at most 30 digits. In addition, it doesn't contain any leading zeros.
Output
For each line, print the first type from the list "short, int, long long", that can store the natural number n. If no one can store the number, just print "It is too big!".
Sample Input
102
50000
123456789101112131415161718192021222324
Sample Output
short
int
It is too big! 简单字符串处理,留作纪念!!!
竟然忘记了strcmp这个函数的强大功能,它的比较是按ASCII码表的。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std; const int maxn = + ;
char s[maxn], t[maxn]; int main()
{
int i, len;
while (gets(s))
{
len = strlen(s);
if (s[] == '-')
{
int l = ;
for (i = ; i < len; i++)
t[l++] = s[i];
if ((strcmp(t, "") <= && l == strlen("")) || l < strlen(""))
puts("short");
else if ((strcmp(t, "") <= && l == strlen("")) || l < strlen(""))
puts("int");
else if ((strcmp(t, "") <= && l == strlen("")) || l < strlen("") )
puts("long long");
else
puts("It is too big!");
}
else
{
if ((strcmp(s, "") <= && len == strlen("")) || len < strlen(""))
puts("short");
else if ((strcmp(s, "") <= && len == strlen("")) || len < strlen(""))
puts("int");
else if ((strcmp(s, "") <= && len == strlen("")) || len < strlen(""))
puts("long long");
else
puts("It is too big!");
}
}
return ;
}
2013 gzhu 校赛的更多相关文章
- SCNU省选校赛第二场B题题解
今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- 2014上半年acm总结(1)(入门+校赛)
大一下学期才开始了acm,不得不说有一点迟,但是acm确实使我的生活充实了很多,,不至于像以前一样经常没事干= = 上学期的颓废使我的c语言学的渣的一笔..靠考前突击才基本掌握了语法 寒假突然醒悟, ...
- 2017CUIT校赛-线上赛
2017Pwnhub杯-CUIT校赛 这是CUIT第十三届校赛啦,也是我参加的第一次校赛. 在被虐到崩溃的过程中也学到了一些东西. 这次比赛是从5.27早上十点打到5.28晚上十点,共36小时,中间睡 ...
- 2013年山东省赛F题 Mountain Subsequences
2013年山东省赛F题 Mountain Subsequences先说n^2做法,从第1个,(假设当前是第i个)到第i-1个位置上哪些比第i位的小,那也就意味着a[i]可以接在它后面,f1[i]表示从 ...
- [蓝桥杯]2013蓝桥省赛B组题目及详解
/*——————————————————————————————————————————————————————————— 题目:2013 高斯日记T-1 问题描述: 大数学家高斯有一个好习惯:无论如 ...
- 2013年省赛H题
2013年省赛H题你不能每次都快速幂算A^x,优化就是预处理,把10^9预处理成10^5和10^4.想法真的是非常巧妙啊N=100000构造两个数组,f1[N],间隔为Af2[1e4]间隔为A^N,中 ...
- 2013年省赛I题 Thrall’s Dream
2013年省赛I题判断单向联通,用bfs剪枝:从小到大跑,如果遇到之前跑过的点(也就是编号小于当前点的点),就o(n)传递关系. bfs #include<iostream> #inclu ...
- HZNU第十二届校赛赛后补题
愉快的校赛翻皮水! 题解 A 温暖的签到,注意用gets #include <map> #include <set> #include <ctime> #inclu ...
随机推荐
- GridControl 校验输入单元格格式 z
// 对应的校验行事件,ValidateRow private void gv_FeeItem_ValidateRow(object sender, DevExpress.XtraGrid.Views ...
- Go -- FIFO类(缓存淘汰算法)(转)
1 FIFO 1.1. 原理 按照“先进先出(First In,First Out)”的原理淘汰数据. 1.2. 实现 FIFO队列,具体实现如下: 1. 新访问的数据插入FIFO队列尾部,数据在FI ...
- jquery 查找子元素的几种方法
<div class="tm-clear tb-hidden tm_brandAttr" id="J_BrandAttr" style="dis ...
- vue doubleclick 鼠标双击事件
Vue-dblclick事件(此外事件还有mouseover,mouseout,click,mousdown...): v-on:dblclick="函数" v-on:click/ ...
- Spring 与 MyBatis 整合
一.实验介绍 1.1 实验内容 本节课程将整合 Spring 和 MyBatis,并采用 Junit 进行单元测试. 1.2 实验知识点 Spring - MyBatis 整合 Junit 单元测试 ...
- XmlNode与XmlElement的区别总结
原文链接:http://www.cnblogs.com/oilsun/archive/2012/07/07/2580427.html 今 天在做ASP.NET操作XML文档的过程中,发现了两个类:Xm ...
- MRP routing设置释疑
Jeffer9@gmail.com 工艺是指在不同工作中心执行的作业序列 作业的详细信息 Number of cycles 在该工作中心操作几个循环 Number of ...
- go mysql dsn
https://github.com/go-sql-driver/mysql#dsn-data-source-name DSN (Data Source Name) The Data Source N ...
- SpringBoot学习之验证信息国际化
以登录为例: 1.controller的登录方法: @RequestMapping("/SSOAuth/login") @ResponseBody public ResponseV ...
- mysql + php 中文乱码 全是? 解决方法
在my.ini文件中找到[client]和[mysqld]字段,在下面均加上default-character-set=utf8,保存并关闭,重启服务器 在window下重启失败,这是因为你安装了高版 ...