Kattis - Oddities

Kattis - Oddities

題目

https://hackmd.io/@sa072686/Kattis_oddities

https://open.kattis.com/problems/oddities

判斷 $n$ 是奇數或是偶數

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//By Koios1143
#include<iostream>
using namespace std;
int main(){
int n,x;
cin>>n;
while(n--){
cin>>x;
if(x%2==0)
cout<<x<<" is even\n";
else
cout<<x<<" is odd\n";
}
return 0;
}

複雜度分析

總時間複雜度為 $O(1)$