【链接】 我是链接,点我呀:)

【题意】

给你一个k位数b进制的进制转换.
让你求出来转成10进制之后这个数字是奇数还是偶数

【题解】

模拟一下转换的过程,加乘的时候都记得对2取余就好

【代码】

  1. import java.io.*;
  2. import java.util.*;
  3. public class Main {
  4. static int N = (int)1e5;
  5. static InputReader in;
  6. static PrintWriter out;
  7. static int b,k;
  8. static int a[];
  9. public static void main(String[] args) throws IOException{
  10. in = new InputReader();
  11. out = new PrintWriter(System.out);
  12. //code start from here
  13. a = new int[N+10];
  14. b = in.nextInt();k = in.nextInt();
  15. for (int i = 1;i <= k;i++) a[i] = in.nextInt();
  16. int now = 1;
  17. long n = 0;
  18. for (int i = k;i >= 1;i--) {
  19. n = (n + a[i]*now)%2;
  20. now = (now * b)%2;
  21. }
  22. if (n%2==1) {
  23. out.println("odd");
  24. }else {
  25. out.println("even");
  26. }
  27. out.close();
  28. }
  29. static class InputReader{
  30. public BufferedReader br;
  31. public StringTokenizer tokenizer;
  32. public InputReader() {
  33. br = new BufferedReader(new InputStreamReader(System.in));
  34. tokenizer = null;
  35. }
  36. public String next(){
  37. while (tokenizer==null || !tokenizer.hasMoreTokens()) {
  38. try {
  39. tokenizer = new StringTokenizer(br.readLine());
  40. }catch(IOException e) {
  41. throw new RuntimeException(e);
  42. }
  43. }
  44. return tokenizer.nextToken();
  45. }
  46. public int nextInt() {
  47. return Integer.parseInt(next());
  48. }
  49. }
  50. }

【Codeforces Global Round 1 A】Parity的更多相关文章

  1. 【Codeforces Global Round 1 E】Magic Stones

    [链接] 我是链接,点我呀:) [题意] 你可以把c[i]改成c[i+1]+c[i-1]-c[i] (2<=i<=n-1) 问你能不能把每一个c[i]都换成对应的t[i]; [题解] d[ ...

  2. 【Codeforces Global Round 1 C】Meaningless Operations

    [链接] 我是链接,点我呀:) [题意] 给你一个a 让你从1..a-1的范围中选择一个b 使得gcd(a^b,a&b)的值最大 [题解] 显然如果a的二进制中有0的话. 那么我们就让选择的b ...

  3. 【 Codeforces Global Round 1 B】Tape

    [链接] 我是链接,点我呀:) [题意] x轴上有m个连续的点,从1标号到m. 其中有n个点是特殊点. 让你用k段区间将这n个点覆盖. 要求区间的总长度最小. [题解] 一开始假设我们需要n个胶带(即 ...

  4. 【Codeforces Beta Round #45 D】Permutations

    [题目链接]:http://codeforces.com/problemset/problem/48/D [题意] 给你n个数字; 然后让你确定,这n个数字是否能由若干个(1..x)的排列连在一起打乱 ...

  5. 【Codeforces Beta Round #88 C】Cycle

    [Link]:http://codeforces.com/problemset/problem/117/C [Description] 问你一张图里面有没有一个三元环,有的话就输出. [Solutio ...

  6. 【手抖康复训练1 】Codeforces Global Round 6

    [手抖康复训练1 ]Codeforces Global Round 6 总结:不想复习随意打的一场,比赛开始就是熟悉的N分钟进不去时间,2333,太久没写题的后果就是:A 题手抖过不了样例 B题秒出思 ...

  7. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  8. Codeforces Global Round 1 (A-E题解)

    Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...

  9. Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)

    Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...

随机推荐

  1. 写web项目注意事项

    1.中文名2.文件存放路径(js css img)3.class详细路径(mydiv.myul li)

  2. 洛谷 P1312 [ NOIP 2011 ] Mayan游戏 —— 搜索+模拟

    题目:https://www.luogu.org/problemnew/show/P1312 还是不擅长这种题,所以参考了一下TJ: 其实也很好搜,按字典序,先搜右移,再搜左移: 不交换相同颜色的两个 ...

  3. Makefile 实际用例分析(二) ------- 比较通用的一种架构

    之前已经讲了这一篇文章:Makefile实际用例分析(一)-----比较通用的一种架构 现在这篇其实和那个差的不是很多,只是在布局上有些差别(这个makefile也是论坛上一起讨论过的,囧,忘了哪个论 ...

  4. 杂项-Java:JMX

    ylbtech-杂项-Java:JMX 1.返回顶部 1. JMX(Java Management Extensions,即Java管理扩展)是一个为应用程序.设备.系统等植入管理功能的框架.JMX可 ...

  5. Coursera Algorithms week4 基础标签表 练习测验:Inorder traversal with constant extra space

    题目原文: Design an algorithm to perform an inorder traversal of a binary search tree using only a const ...

  6. (转)容易遗忘的JS知识点整理

    1.hasOwnProperty相关 为了判断一个对象是否包含自定义属性而不是原型链上的属性,我们需要使用继承自 Object.prototype 的 hasOwnProperty方法.hasOwnP ...

  7. html5——css选择器

    复习 div>p: 子代 div+p:div后面相邻的第一个p div~p: div后面所有的兄弟p 属性选择器 标志:[]:区别于id选择器:#,区别于类名选择器:. 特殊符号:^:开头    ...

  8. iframe监听unload事件

    阻止默认事件 event.preventDefault(); 阻止事件冒泡 event.stopPropagation(); event.cancelBubble = true; //IE <a ...

  9. C#斐波那契数列方法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. spring IOC bean中注入集合

    建立一个实体 package com.java.test4; import java.util.*; /** * @author nidegui * @create 2019-06-22 14:45 ...