【Codeforces Global Round 1 A】Parity
【链接】 我是链接,点我呀:)
【题意】
给你一个k位数b进制的进制转换.
让你求出来转成10进制之后这个数字是奇数还是偶数
【题解】
模拟一下转换的过程,加乘的时候都记得对2取余就好
【代码】
import java.io.*;
import java.util.*;
public class Main {
static int N = (int)1e5;
static InputReader in;
static PrintWriter out;
static int b,k;
static int a[];
public static void main(String[] args) throws IOException{
in = new InputReader();
out = new PrintWriter(System.out);
//code start from here
a = new int[N+10];
b = in.nextInt();k = in.nextInt();
for (int i = 1;i <= k;i++) a[i] = in.nextInt();
int now = 1;
long n = 0;
for (int i = k;i >= 1;i--) {
n = (n + a[i]*now)%2;
now = (now * b)%2;
}
if (n%2==1) {
out.println("odd");
}else {
out.println("even");
}
out.close();
}
static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer;
public InputReader() {
br = new BufferedReader(new InputStreamReader(System.in));
tokenizer = null;
}
public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
【Codeforces Global Round 1 A】Parity的更多相关文章
- 【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[ ...
- 【Codeforces Global Round 1 C】Meaningless Operations
[链接] 我是链接,点我呀:) [题意] 给你一个a 让你从1..a-1的范围中选择一个b 使得gcd(a^b,a&b)的值最大 [题解] 显然如果a的二进制中有0的话. 那么我们就让选择的b ...
- 【 Codeforces Global Round 1 B】Tape
[链接] 我是链接,点我呀:) [题意] x轴上有m个连续的点,从1标号到m. 其中有n个点是特殊点. 让你用k段区间将这n个点覆盖. 要求区间的总长度最小. [题解] 一开始假设我们需要n个胶带(即 ...
- 【Codeforces Beta Round #45 D】Permutations
[题目链接]:http://codeforces.com/problemset/problem/48/D [题意] 给你n个数字; 然后让你确定,这n个数字是否能由若干个(1..x)的排列连在一起打乱 ...
- 【Codeforces Beta Round #88 C】Cycle
[Link]:http://codeforces.com/problemset/problem/117/C [Description] 问你一张图里面有没有一个三元环,有的话就输出. [Solutio ...
- 【手抖康复训练1 】Codeforces Global Round 6
[手抖康复训练1 ]Codeforces Global Round 6 总结:不想复习随意打的一场,比赛开始就是熟悉的N分钟进不去时间,2333,太久没写题的后果就是:A 题手抖过不了样例 B题秒出思 ...
- CodeForces Global Round 1
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...
- Codeforces Global Round 1 (A-E题解)
Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...
- Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)
Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...
随机推荐
- 【HNOI 2003】 激光炸弹
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1218 [算法] 二维前缀和 [代码] #include<bits/stdc++ ...
- SpringBoot 启动定时任务
再项目中大多会使用定时任务来定时执行一些操作,如:文件迁移,备份等等.今天就来跟大家一起学习下如何在SpringBoot中创建定时任务. 1.新建SpringBoot项目,或在原有的项目上添加(不知道 ...
- Linux 用户管理(1) (/etc/passwd)
Linux所有的用户都在/etc/passwd文件里面. 1.为什么需要用户 1)计算机及网络资源的合理分配 2)可以控制用户访问系统的权限.3)身份认证 4) 进程 以某个用户的身份来运行 2.用 ...
- JavaScript中.和[]有什么区别?
.与[]都可以用于读取或修改对象属性. <script> var myData={ name:"Adam", weather:"sunny", }; ...
- Java8080端口被占用解决办法
netstat -ano | findstr 8080 taskkill -pid 3196-f
- Java系列学习(十一)-内部类
1.内部类 (1)把类定义在另一个类的内部,该类就称为内部类 (2)内部类的访问规则 A:内部类可以直接访问外部类的成员,包括私有 B:外部类要想访问内部类的成员,必须创建对象 (3)内部类的分类 A ...
- Python随笔-快排
def swap(arr, i, j): temp = arr[i] arr[i] = arr[j] arr[j] = temp def part(arr, beg, end): : return b ...
- JVM中线程状态转换图
JVM中线程的状态转换图 线程在一定条件下,状态会发生变化.线程一共有以下几种状态: 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnable):线程对象创建后,其他线程调用了该 ...
- cordova科大讯飞语音识别
cordova-plugin-IFlyspeech 科大讯飞的语音听说读写的cordova插件 Supported Platforms iOS android Installation 插件安装命令: ...
- Android HTTP 数据提交
在Android 项目中,使用HTTP协议获取数据或者处理数据,需要使用到多线程和配置相应的APP权限 1.使用线程,使用HTTP 提交数据 private Thread submitThread = ...