Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4. int arr[1000002] ;
  5. int main()
  6. {
  7.     int i , n , t ;
  8.     long long sum = 0 ;
  9.     arr[1] = 1 ;
  10.     for ( int j = 2 ; j <1000000 ; j ++ )
  11.     {
  12.         arr[j] = arr[j-1] +  j*j*j ;
  13.         arr[j] = arr[j] %1000000003;
  14.     }
  15.     scanf ("%d",&t);
  16.     for ( i = 0 ; i < t ; i ++ )
  17.     {
  18.         sum = 0 ;
  19.         scanf ("%d",&n) ;
  20.  
  21.         for ( int j = 1 ; j <= n ; j ++ )
  22.            sum += arr[j];
  23.  
  24.        printf ("%lld",sum);
  25.     }
  26.     return 0;
  27. }