Guest User

killjee and easy problem

a guest
Aug 5th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. /**
  6.  * Created by bugkiller on 7/15/2017.
  7.  */
  8. public class KilljeeAndEasyProblem {
  9.  
  10.     static int a[]=new int[100000];
  11.     static long M=10000000011L;
  12.     public static void main(String[] args) throws IOException {
  13.  
  14.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  15.         int n;
  16.         String[]s;
  17.         n = Integer.parseInt(br.readLine());
  18.         s = br.readLine().split("\\s");
  19.  
  20.         for (int i = 0; i < n; i++) {
  21.             a[i] = Integer.parseInt(s[i]);
  22.         }
  23.  
  24.         System.out.println(solve(n));
  25.     }
  26.  
  27.     private static long solve(int n) {
  28.         int cnt;
  29.         long sum=0;
  30.         for (int i = 0; i < n; i++) {
  31.             cnt=0;
  32.             for (int j = 0; j < 32; j++) {
  33.                 if ((a[i] & (1 << j)) > 0) {
  34.                     cnt++;
  35.                 }
  36.             }
  37.             System.out.println(cnt);
  38.  
  39.             sum = (sum + moduloExp(cnt, i + 1,M)) % M;
  40.  
  41.         }
  42.         return sum;
  43.     }
  44.  
  45.     public static long moduloExp(long  cnt, int exp,long M) {
  46.  
  47.         long ans=1;
  48.         while (exp>0){
  49.             if (exp%2==1)
  50.                 ans=(ans*cnt)%M;
  51.  
  52.             cnt=(cnt*cnt)%M;
  53.  
  54.             exp>>=1;
  55.         }
  56.         return ans;
  57.     }
  58. }
Add Comment
Please, Sign In to add comment