this approach is giving tle for test cases …could suggest and better approach
Matrix query approach issue
even this code you have shown here is giving run error for 2 test cases…please help
source.cpp:11:36: error: invalid operands of types ‘int’ and 'int ()[2]’ to binary ‘operator%’
11 | r[0][0]=(((a[0][0])( b[0][0]))%r+(a[0][1]*b[1][0])%r)%r;
| ~~~~~~~~~~~~~~~~~~~~~~^~
| | |
| int int (*)[2]
showing this error at lots of places…i tried correcting nothing helped and its taking huge time to compile…something doesnt seem right
@rohit_1906 hey this is corrected c++ code,and is submiting on mine ,so please check that language is C++ and you are using correct input.
yaa its giving error just do this below changes,
int n,rmod,q;
void multiply(int a[2][2],int b[2][2],int r[2][2])
{
r[0][0]=(a[0][0]*b[0][0]+a[0][1]*b[1][0])%rmod;
r[0][1]=(a[0][0]*b[0][1]+a[0][1]*b[1][1])%rmod;
r[1][0]=(a[1][0]*b[0][0]+a[1][1]*b[1][0])%rmod;
r[1][1]=(a[1][0]*b[0][1]+a[1][1]*b[1][1])%rmod;
}
As before you were dividing the 2*2 matrix instead of the given rmod.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.