Simply Loopy |
Given an integer n, print what the following function (written in C++) will return:
long long unsigned lol(int n) { long long unsigned ret = 0 , i , j , k , l , m , M = 7477777 ; for( i = 1 ; i <= n ; i++ ) for( j = 1 ; j <= n ; j++ ) for( k = 1 ; k <= n ; k++ ) for( l = 1 ; l <= n ; l++ ) for( m=1 ; m <= n ; m++ ) if( i + j + k + l + m == n ) ret = (ret + i*i + j*j + k*k + l*l + m*m)%M ; return ret ; }
Note: A straight forward implementation of the given function may take millions of years,
even for the fastest computers!
3 5 6 7
Case 1: 5 Case 2: 40 Case 3: 175
Problem Setter: Momontho Mashak Monmoy
Alternate Solution: Muhammad Ridowan, Md. Shiplu Hawlader