题目描述

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. PageBarHelper分页显示类

    一共有两个分页类,都可以使用(单独使用) using System;using System.Collections.Generic;using System.Linq;using System.Te ...

  2. js 使用script或template标签:分离js代码template中的HTML元素

    参考:https://www.jianshu.com/p/332252abe016 方法一. script: <div id="app"> <com-first& ...

  3. MFC ,List使用

    出自http://www.cnblogs.com/yuehui/archive/2012/06/15/2550449.html List容器双向线性表list容器   list类定义了双向的线性表.V ...

  4. GetCommandLine CmdLineToArgvW

    说明:LPTSTR GetCommandLine(VOID); LPWSTR * CommandLineToArgvW(                                        ...

  5. JZOJ5870 【NOIP2018模拟9.15】地图

    题目描述 Description

  6. Python技巧—list与字符串互相转换

    Python技巧-list与字符串互相转换 在Python的编程中,经常会涉及到字符串与list之间的转换问题,下面就将两者之间的转换做一个梳理. 1.list转换成字符串 命令:list() 例子: ...

  7. PAT甲级——A1050 String Subtraction

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  8. maximum clique 1

    maximum clique 1 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288KSpecial Judge, 64bit IO Format: % ...

  9. springcloud的服务提供者与服务消费者

    1.说明 springcloud中由服务消费者调用服务提供者一共有两种方法rest和feign 2.feign (1)使用feign的方式进行服务调,搭建服务提供者. 创建一个web项目(服务提供者) ...

  10. Java 函数优雅之道

    导读 随着软件项目代码的日积月累,系统维护成本变得越来越高,是所有软件团队面临的共同问题.持续地优化代码,提高代码的质量,是提升系统生命力的有效手段之一.软件系统思维有句话“Less coding, ...