markdown AtCoder Grand Contest 016
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown AtCoder Grand Contest 016相关的知识,希望对你有一定的参考价值。
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
// InputStream inputStream = System.in;
// OutputStream outputStream = System.out;
// InputReader in = new InputReader(inputStream);
// PrintWriter out = new PrintWriter(outputStream);
// TaskD solver = new TaskD();
// solver.solve(in, out);
Solution sol = new Solution();
int[] A = new int[6];
A[0]= 1;
A[1]= 0;
A[2]= 2;
A[3]= 0;
A[4]= 0;
A[5]= 2;
int ans = sol.solution(A);
System.out.println(ans);
// out.close();
}
public int solution(int[] A){
int binarian = 0;
for(int i =0; i<A.length; i++){
binarian += Math.pow(2,A[i]);
}
String bin = Integer.toBinaryString(binarian);
int count = 0;
for(int i=0; i<bin.length(); i++){
if(bin.charAt(i)=='1'){
count+=1;
}
}
return count;
}
static class TaskD {
public void solve(InputReader in, PrintWriter out) {
int n = in.nextInt();
int[] a = new int[n+1];
for(int i =0; i<n;i++){
a[i] = in.nextInt();
a[n] ^= a[n];
}
int[] b = new int[n+1];
for(int i =0; i<n;i++){
b[i] = in.nextInt();
b[n] ^= b[i];
}
int[] ca = Arrays.copyOf(a, n+1);
int[] cb = Arrays.copyOf(b, n+1);
AUtils.sort(ca);
AUtils.sort(cb);
for(int i=0; i<=n; i++){
if(ca[i] != cb[i]){
out.println(-1);
break;
}
}
}
}
static class AUtils {
public static void sort(int[] arr) {
for (int i = 1; i < arr.length; i++) {
int j = (int) (Math.random() * (i + 1));
if (i != j) {
int t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
}
Arrays.sort(arr);
}
}
//input
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
# AtCoder Grand Contest 016
以上是关于markdown AtCoder Grand Contest 016的主要内容,如果未能解决你的问题,请参考以下文章
AtCoder Grand Contest 006
AtCoder Grand Contest 008 题解
AtCoder Grand Contest 025 Problem D
AtCoder Grand Contest 019
AtCoder Grand Contest 003
AtCoder Grand Contest 009 题解