Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /**
- * Created by bugkiller on 7/15/2017.
- */
- public class KilljeeAndEasyProblem {
- static int a[]=new int[100000];
- static long M=10000000011L;
- public static void main(String[] args) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- int n;
- String[]s;
- n = Integer.parseInt(br.readLine());
- s = br.readLine().split("\\s");
- for (int i = 0; i < n; i++) {
- a[i] = Integer.parseInt(s[i]);
- }
- System.out.println(solve(n));
- }
- private static long solve(int n) {
- int cnt;
- long sum=0;
- for (int i = 0; i < n; i++) {
- cnt=0;
- for (int j = 0; j < 32; j++) {
- if ((a[i] & (1 << j)) > 0) {
- cnt++;
- }
- }
- System.out.println(cnt);
- sum = (sum + moduloExp(cnt, i + 1,M)) % M;
- }
- return sum;
- }
- public static long moduloExp(long cnt, int exp,long M) {
- long ans=1;
- while (exp>0){
- if (exp%2==1)
- ans=(ans*cnt)%M;
- cnt=(cnt*cnt)%M;
- exp>>=1;
- }
- return ans;
- }
- }
Add Comment
Please, Sign In to add comment