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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int n = 2005;
  13. int[] a = new int[n*n];
  14. for (int i=0; i<2005; i++) a[i] = i+1;
  15. for (int i=0, j=2005; i<=n-1; i+=2, j++) a[j] = a[i] + a[i+1];
  16. long s = 0;
  17. for (int i=0; i<n*n; i++) s += a[i];
  18. System.out.println(s);
  19. }
  20. }
Success #stdin #stdout 0.1s 71060KB
stdin
45
stdout
4022033