A. Paritytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer nn

(n≥0n≥0

) represented with kk

digits in base (radix) bb

. So,n=a1⋅bk−1+a2⋅bk−2+…ak−1⋅b+ak.n=a1⋅bk−1+a2⋅bk−2+…ak−1⋅b+ak.

For example, if b=17,k=3b=17,k=3

and a=[11,15,7]a=[11,15,7]

then n=11⋅172+15⋅17+7=3179+255+7=3441n=11⋅172+15⋅17+7=3179+255+7=3441

.Determine whether nn

is even or odd.InputThe first line contains two integers bb

and kk

(2≤b≤1002≤b≤100

, 1≤k≤1051≤k≤105

) — the base of the number and the number of digits.The second line contains kk

integers a1,a2,…,aka1,a2,…,ak

(0≤ai<b0≤ai<b

) — the digits of nn

.The representation of nn

contains no unnecessary leading zero. That is, a1a1

can be equal to 00

only if k=1k=1

.OutputPrint “even” if nn

is even, otherwise print “odd”.You can print each letter in any case (upper or lower).ExamplesInputCopy13 3
3 2 7
OutputCopyeven
InputCopy10 9
1 2 3 4 5 6 7 8 9
OutputCopyodd
InputCopy99 5
32 92 85 74 4
OutputCopyodd
InputCopy2 2
1 0
OutputCopyeven
NoteIn the first example, n=3⋅132+2⋅13+7=540n=3⋅132+2⋅13+7=540

, which is even.In the second example, n=123456789n=123456789

is odd.In the third example, n=32⋅994+92⋅993+85⋅992+74⋅99+4=3164015155n=32⋅994+92⋅993+85⋅992+74⋅99+4=3164015155

is odd.In the fourth example n=2n=2

.

#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
using namespace std;
long long int n[100010];
int main()
{long long int a,b,c,i,sum=0;cin >> a >> b;for(i=b; i>0; i--){cin >> c;if(a%2!=0){if(i==1){if(c%2!=0){n[i]=1;}else{n[i]=2;}}else{if(c%2!=0){n[i]=1;}else{n[i]=2;}}}else{if(i==1){if(c%2!=0){n[i]=1;}else{n[i]=2;}}else{n[i]=2;}}}for(i=b; i>0; i--){sum=sum+n[i];}if(sum%2==0){cout << "even";}else{cout << "odd";}return 0;
}

codeforces A. Parity相关推荐

  1. CodeForces 297A Parity Game (脑补题)

    题意 一个01串,可以有两种操作:①在末尾添加parity(a):②删除开头的一个字符.其中parity(a),当串中1的个数为奇数时为1,偶数时为0.问某个01串是否可以通过若干操作变成另一个01串 ...

  2. Codeforces 979E Kuro and Topological Parity - 动态规划 - 组合数学

    题目传送门 传送点 题目大意 给定$n$个标号依次为$1, 2, \cdots, n$的点,其中一些点被染成一些颜色,剩下的点没有染色.你需要添加一些有向边并将剩下的点染色,满足有向边从编号小的一端指 ...

  3. Parity Game CodeForces - 298C

    You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears ...

  4. 【CodeForces - 298C】Parity Game (思维,有坑)

    题干: You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar be ...

  5. CodeForces - 1272E Nearest Opposite Parity(多源起点的最短路)

    题目链接:点击查看 题目大意:给出 n 个点,每个点都有一个权值 a[ i ],且每个点可以到达 ( i - a[ i ] ) 和 ( i + a[ i ] ) 两个位置,花费为 1,问每个点到达与其 ...

  6. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

  7. Codeforces Round #640 (Div. 4)(ABCDE)

    Sum of Round Numbers CodeForces - 1352A 思路:按照题意模拟即可. 代码如下: #include<bits/stdc++.h> #define ll ...

  8. Codeforces Round #371 (Div. 2) C. Sonya and Queries —— 二进制压缩

    题目链接:http://codeforces.com/contest/714/problem/C C. Sonya and Queries time limit per test 1 second m ...

  9. Codeforces Round #371 (Div. 2) C. Sonya and Queries 水题

    C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learn ...

  10. codeforces 1367B - Even Array

    B. Even Array time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...

最新文章

  1. Python 之协程
  2. 【若依(ruoyi)】部门查询SQL
  3. python3.6字典有序_为什么从Python 3.6开始字典有序并效率更高
  4. android+button+不可点击置灰,android:tint 给imagebutton着色 按钮灰色
  5. 作者:程文亮(1989-),男,华东师范大学数据科学与工程研究院硕士生
  6. 漫画:35岁的IT会不会失业?
  7. 20190724算法题存档
  8. 自动驾驶汽车寿命只有四年?
  9. python 数组去重复_numpy数组去掉重复的行,保留唯一的行数据
  10. java实验二 类和对象
  11. 如何将自己的网站分享到QQ空间,微信,微博等等。
  12. html 音乐能连续播放吗,音乐在不同HTML页面的连续播放问题
  13. 'tensorflow' has no attribute 'sub'
  14. 手机发包工具_【发包工具】http多线程发包工具
  15. okvis odometry的安装与运行
  16. NodeJs安装教程:看教程一步步学会安装NodeJs
  17. 【PAT】A1150 Travelling Salesman Problem【中国邮递员问题】
  18. 英语——句子结构和成分大全【学习笔记】
  19. wps中怎么在奇数页的页眉中设置整本书的标题,而在偶数页中设置该章的标题,同时请问怎样修改页码的字体?
  20. 浏览器上方的工具栏不见了_IE浏览器上面的工具栏都不见了 怎么办

热门文章

  1. ps图层模式详解带计算公式
  2. 静态资源文件无法加载导致jsp页面渲染不成功问题
  3. 学霸的迷宫 - 广搜例题
  4. HTC M7日文版HTL22刷机包 毒蛇2.5.0 ART NFC Sense6.0
  5. python 图片文字提取
  6. 【超级表格创业谱】王庆刚:你的岗位有没有辜负你的才华?
  7. 加密流量分类-论文2:Deep Packet: A Novel Approach For Encrypted Traffic Classification Using Deep Learning
  8. androidnbsp;软件apk
  9. iphone计算机能算度分秒吗,‎App Store 上的“图形计算器”
  10. html中target四种选择_blank、_parent、_self、_top,分别是什么意思?