here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Wednesday 29 October 2014

A Summatory

problem statement is here


#include <stdio.h>
#define M 1000010

int t,c;
long long int sum[M];

int main(){
      long long int i, a = 0;
           for (i = 1; i < M; i++){
                  a = (a + i*i*i) % 1000000003;
                  sum[i] = (sum[i-1] + a) % 1000000003;
                   }
           scanf("%d", &t);
           while (t--){
              scanf("%d", &c);
              printf("%lld\n", sum[c]);
               }
           return 0;
}

1 comment: