题目描述

Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive integers I (1 <= I <= 10^60) for which Bessie must determine their parity (explained in second grade as 'Even... or odd?'). Bessie is overwhelmed by the size of the list and by the size of the numbers. After all, she only learned to count recently.

Write a program to read in the N integers and print 'even' on a single line for even numbers and likewise 'odd' for odd numbers.

POINTS: 25

Bessie那惨无人道的二年级老师搞了一个有 N 个正整数 I 的表叫Bessie去判断“奇偶性”(这个词语意思向二年级的学生解释,就是“这个数是单数,还是双数啊?”)。Bessie被那个表的长度深深地震惊到了,竟然跟栋栋的泛做表格一样多道题!!!毕竟她才刚刚学会数数啊。

写一个程序读入N个整数,如果是双数,那么在单立的一行内输出"even",如果是单数则类似地输出"odd".

输入输出格式

输入格式:

  • Line 1: A single integer: N

  • Lines 2..N+1: Line j+1 contains I_j, the j-th integer to determine even/odd

输出格式:

  • Lines 1..N: Line j contains the word 'even' or 'odd', depending on the parity of I_j

输入输出样例

输入样例#1: 复制

2
1024
5931
输出样例#1: 复制

even
odd

说明

Two integers: 1024 and 5931

1024 is eminently divisible by 2; 5931 is not

【代码】:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
char a[1005];//是大数 用字符串
cin>>n;
while(n--)
{
scanf("%s",a);
if((a[strlen(a)-1]-'0')%2==0)//判断奇偶只要看最后一位
puts("even");
else
puts("odd");
}
return 0;
}

  

洛谷 P2955 [USACO09OCT]奇数偶数Even? Odd?【字符串/易错】的更多相关文章

  1. P2955 [USACO09OCT]奇数偶数Even? Odd?

    题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive int ...

  2. 题解 P2955 【[USACO09OCT]奇数偶数Even? Odd? 】

    很明显这题是个假入门! 小金羊一不小心点进题解发现了内幕 能看的出来都WA过Unsigned long long int 做题可以用Python,Python的变量虽然 强悍的不行! 但是我们可以用字 ...

  3. 洛谷P3832 [NOI2017]蚯蚓排队 【链表 + 字符串hash】

    题目链接 洛谷P3832 题解 字符串哈希然后丢到hash表里边查询即可 因为\(k \le 50\),1.2操作就暴力维护一下 经复杂度分析会发现直接这样暴力维护是对的 一开始自然溢出WA了,还以为 ...

  4. 洛谷 P2376 [USACO09OCT]津贴Allowance 解题报告

    P2376 [USACO09OCT]津贴Allowance 题目描述 作为创造产奶纪录的回报,\(Farmer\) \(John\)决定开始每个星期给\(Bessie\)一点零花钱. \(FJ\)有一 ...

  5. 洛谷——P2958 [USACO09OCT]木瓜的丛林Papaya Jungle

    P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer ...

  6. 洛谷—— P1339 [USACO09OCT]热浪Heat Wave

    P1339 [USACO09OCT]热浪Heat Wave 题目描述 The good folks in Texas are having a heatwave this summer. Their ...

  7. 洛谷 P2959 [USACO09OCT]悠闲漫步The Leisurely Stroll

    P2959 [USACO09OCT]悠闲漫步The Leisurely Stroll 题目描述 Bessie looks out the barn door at the beautiful spri ...

  8. 洛谷 P2960 [USACO09OCT]Milkweed的入侵Invasion of the Milkweed

    P2960 [USACO09OCT]Milkweed的入侵Invasion of the Milkweed 题目描述 Farmer John has always done his best to k ...

  9. 洛谷 P2958 [USACO09OCT]木瓜的丛林Papaya Jungle

    P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer ...

随机推荐

  1. mvvmlight下passwordBox绑定的解决方法

    在做公司的项目中,用到MVVMLight框架,需要做登陆注册的功能模块,但是在wpf中passwordBox没有内置绑定功能,因为出于安全的考虑.但是,博主又非常想要契合mvvm思想,一定要passw ...

  2. Centos7解决在同一局域网内无法使用ssh连接

    参考: https://www.cnblogs.com/liyuanhong/articles/5785368.html 一.修改网卡设置 nano /etc/sysconfig/network-sc ...

  3. spring中的ResponseEntity理解

    参考: https://blog.csdn.net/weixin_37869477/article/details/82762976 https://blog.csdn.net/sswqzx/arti ...

  4. Unity 用代码设置UGUI的渲染层级

    用代码设置UGUI渲染无非和三个API有关: 1.SetAsFirstSibling(); 2.SetAsLastSibling(); 3.SetSiblingIndex(n) SetAsFirstS ...

  5. css的书写位置+元素分类

    1.css的书写位置 1>行内样式: <span style="color:red;">haha</span> 2>内部样式 在style标签中 ...

  6. dubbo入门学习(二)-----dubbo hello world

    一.dubbo hello world入门示例 1.提出需求 某个电商系统,订单服务需要调用用户服务获取某个用户的所有地址: 我们现在需要创建两个服务模块进行测试: 模块 功能 订单服务web模块 创 ...

  7. 软件-DiskSpeekUp:DiskSpeekUp(磁盘整理工具)

    ylbtech-软件-DiskSpeekUp:DiskSpeekUp(磁盘整理工具) Disk SpeedUP是一个完全自由和极快的碎片整理工具来分析,碎片整理和优化计算机性能的峰值磁盘. 它是安全没 ...

  8. vue 路由重定向

  9. linux下C++遍历文件夹下的全部文件;Windows/Linux下C++批量修改文件名,批量删除文件

    Linux下 C++遍历目录下所有文件 rename(image_path.c_str(), image_path_new.c_str()); remove(image_path_move.c_str ...

  10. 手机前端开发调试利器-vConsole

    最近因为做抽奖页面,在android上可以使用手机连上电脑后用chrome浏览器chrome://inspect进行页面探测,但是ios中的页面就不能这样探测 在网上搜索后发现此插件,大大解决了问题 ...