In last div 3 round in C-LR i had a problem for deviding a big nunmber with a small one. I am new to programming. Note: i tried unsigned long long x; but still same
#include<bits/stdc++.h>
#define ll long long
#define str string
#define fori(i,a,N) for (int i=a;i<N;i++)
using namespace std;
vector<int> prefix(vector<int> arr) {
int n = arr.size();
vector<int> ps(n);
ps[0] = arr[0];
for (int i = 1; i < n; i++) {
ps[i] = ps[i — 1] + arr[i];
}
return ps;
}
int main()
{
int t;
cin>>t;
while(t--){
int N,M;
cin>>N>>M;
vector<int>A(N);
string S;
ll x=1;
for(int i=0;i<N;i++){
cin>>A[i];
x*=A[i];
}
cin>>S;
cout<<x%M<<" ";
int l=0,r=N-1;
fori(i,0,N-1){
if(S[i]=='L'){
x/=A[l];
l++;
cout<<x%M<<" ";
}
else if(S[i]=='R'){
x/=A[r];
r--;
cout<<x%M<<" ";
}
}
cout<<endl;
}
}
Here when the value of x becomes more than 10^20, dividing it with numbers like 34,57 or any small type number doesnt give correct output.for that x%M is also comes wrong.what should i do? And also is the code logic correct? I know it will always bottle neck if inputs are big numbers. But for small numbers what do i have to modify?