
Yesterday I got this question in a task. I thought I encoded it correctly, and my test case was accepted. However, there was not even one test for the backend. Here is my code. Please someone help me. The problem is solved for me, and therefore I can not imagine it further. But I want to learn from my mistakes. Thank.
import java.io.*;
public class TestClass {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter wr = new PrintWriter(System.out);
int n = Integer.parseInt(br.readLine().trim());
String[] arr_a = br.readLine().split(" ");
int[] a = new int[n];
for(int i_a=0; i_a<arr_a.length; i_a++)
{
a[i_a] = Integer.parseInt(arr_a[i_a]);
}
long out_ = solve(a);
System.out.println(out_);
wr.close();
br.close();
}
static long solve(int[] a){
long sum = 0l;
long MAX = 10000000011l;
long i = 1l;
for(int x : a) {
long count = 0;
while(x>0) {
x &= (x-1l);
count++;
}
long res = 1l;
long temp = i;
count = count % MAX;
while(temp > 0) {
if((temp & 1l) == 1l) {
res = (res * count) % MAX;
}
temp = temp >> 1l;
count = ((count % MAX) * (count % MAX)) % MAX;
}
long t =((sum%MAX) + (res % MAX))%MAX;
sum = t;
i++;
}
return sum;
}
}
source
share