division by n can leave only n remainder [ 0. . n - 1 ] . dp [ i ] [ j ] indicates number of subsequences in string [ 0. . i ] which leaves remainder j after division by n .
int dp [ len ] [ n ] ; memset ( dp , 0 , sizeof ( dp ) ) ;