![:(](./images/smilies/icon_frown.gif)
anybody please explain the statement....
Moderator: Board moderators
Code: Select all
#include "iostream"
using namespace std;
void process(unsigned long int n,unsigned long int k ,unsigned long int d)
{
unsigned long int h;
unsigned long int x[50];
unsigned long int y[50];
for( unsigned long int i=0;i<n;i++)
{
cin>>h;
x[i]=h;
y[i]=h;
}
for( unsigned long int j=0;j<k;j++)
{
for (unsigned long int i = 1;i<n; i++)
{
int next=0,pre=0;
if((i-d)<0)
{
pre=n-(d-i);
}
else
{
pre=i-d;
}
if((i+d)>(n-1))
{
next=(n-(i+1))*(-1);
}
else
{
next=i+d;
}
x[i]=y[next]+y[pre];
}
x[0]=y[d]+y[n-d];
for ( int r = 0;r != n; r++)
{
y[r]=x[r];
}
}
unsigned long int min =x[0];
for ( unsigned long int i = 0;i != n; i++)
{
x[i]=x[i]%n;
if(x[i]<min)
{
min=x[i];
}
}
cout<<min<<endl;
for ( unsigned long int i = 0;i != n; i++)
{
//cout<<x[i];
if(x[i]==min)
{
cout<<i+1<<" ";
}
}
cout<<endl;
}
int main()
{
unsigned long int t,n,d;
unsigned long int k;
cin>>t;
for( unsigned long int i=0;i<t;i++)
{
cin>>n>>k>>d;
process(n,k,d);
}
return 0;
}
please explain in more how we can use matrices multiplication to solve this problem, i tried to apply this idea but i couldn't understand the relevant between matrices multiplication and this problembrianfry713 wrote:You can solve this using matrix multiplication.