Hello, as the title says, I don’t understand the expected output for the IDXSUM problem.
Let’s focus on the second test case from the example.
For M = 3, N = 5, P = “nan”, we are supposed to get S0 = 555099525.
With my code, I get S0 = 152974748, so I wrote a bruteforce code in an attempt to debug.
As I understand it, S0 is the sum of indices of all 5-letter strings that do not end with ‘n’, mod 998,244,353.
So I wrote the following:
int numStrings = 11881376; // 26^5
int res = 0;
char lastLetter = 'a';
for(int i = 0; i < numStrings; ++i)
{
if(lastLetter != 'n')
res = (res + i) % 998244353;
if(lastLetter == 'z')
lastLetter = 'a';
else
++lastLetter;
}
cerr << res << endl;
The output is 152974748.
Am I misunderstanding something in the problem statement?