fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static int digcount(int n)
  11. {
  12. int ans=0;
  13. while(n!=0)
  14. {
  15. n/=10;
  16. ans++;
  17. }
  18. return ans;
  19. }
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. // your code goes here
  23. Scanner sc=new Scanner(System.in);
  24. int n=sc.nextInt();
  25. int b[]=new int[n+1];
  26.  
  27. for(int i=1;i<=n;i++)
  28. b[i]=sc.nextInt();
  29.  
  30. int ans=0;
  31. int sum=0;
  32. for(int j=1;j<=n;j++)
  33. {
  34. int temp=digcount(b[j]);
  35. int val=(j-1)*b[j] +(sum * (int) (Math.pow(10,temp)));
  36. ans+=val;
  37. sum+=b[j];
  38. }
  39.  
  40. System.out.println(ans);
  41.  
  42.  
  43. }
  44. }
Success #stdin #stdout 0.14s 56572KB
stdin
3
3 14 15
stdout
2044