Problem analysis

 Write the number N as a multiple of 4's and 5's.

 In equation form:

            N = k1*4 + k2*5               k1, k2 integers

   <==>     k2*5 = N - k1*4

   <==>     k2 = (N - k1*4) / 5
  

We can use a brute force search method to find k1 and k2

Brute force search method for S1

 Write the number N as a multiple of 4's and 5's.

            k2 = (N - k1*4) / 5      k1, k2 integers


int nSols = 0; for ( k1 = 0; k1 < N/4; k1++ ) { k2 = (N - k1*4) / 5; // k2 may not be an integer if ( k1*4 + k2*5 == N ) nSol++; }

We can use a brute force search method to find k1 and k2