Digvijay vs Supriya - EDITORIAL

#PROBLEM LINK:
contest

#PREREQUISITES:
Basic Mathematics, Modular-arithematic

#Problem:
Given a base K and number M and a String.
We have to convert this string moving from left to right and output the result at every step which contains the modulus M
of decimal representation of the substring encountered till now.

#Explanation:
Starting from left, to find the value at current index, multiply the value at previous index by the given base and add the value at current index in a given string to it an take modulus M at every step.

#include <iostream.h>
#include <string.h>
using namespace std;
int t , k , m , temp;
char str[10001];

int main(int argc, char const *argv[])
{
	scanf("%d" , &t);
	while(t--) {
		scanf("%d %d" , &k , &m);
		scanf("%s" , str);
		int len = strlen(str);
		temp = 0;
		for (int i = 0; i < len; ++i)
		{
			temp = ( (temp*k)%m + (int)(str[i]-'0') ) %m;
			printf("%d ", temp);
		}
		printf("\n");
	}
	return 0;
}