NC24844. [USACO 2009 Oct G]Even? Odd?
描述
输入描述
* Line 1: A single integer: N
* Lines 2..N+1: Line j+1 contains , the j-th integer to determine even/odd
输出描述
* Lines 1..N: Line j contains the word 'even' or 'odd', depending on the parity of
示例1
输入:
2 1024 5931
输出:
even odd
说明:
Two integers: 1024 and 5931C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 496K, 提交时间: 2020-02-17 21:32:32
#include<bits/stdc++.h> using namespace std; int main() { int N,a; char b[100000]; cin>>N; while(N--) { cin>>b; a=b[strlen(b)-1]-'0'; if(a%2==0) cout<<"even\n"; else cout<<"odd\n"; } }
Pascal(fpc 3.0.2) 解法, 执行用时: 2ms, 内存消耗: 256K, 提交时间: 2019-08-30 09:13:14
var i,n,a:longint; s:string; begin readln(n); for i:=1 to n do begin readln(s); if odd(ord(s[length(s)])) then writeln('odd') else writeln('even'); end; end.
Python3(3.5.2) 解法, 执行用时: 34ms, 内存消耗: 3344K, 提交时间: 2019-08-30 10:07:20
for t in range(int(input())):print('odd' if int(input()) % 2 else 'even')