Assignment 6 Question 3
#include <stdio.h>
int main()
{
int n,m;
scanf("%d %d", &m ,&n );
int s[n];
s[0]=m;
int i=1;
int j=0;
int flag=0;
int count=1;
for(i=1;i<n;i++)
{
s[i]=(2*s[i-1])%n;
for(j=0;j<i;j++)
{
if(i==j)
{
continue;
}
if(s[i]==s[j])
{
flag=1;
}
}
if(flag)
{
break;
}
count++;
}
printf("%d", count);
return 0;
}
int main()
{
int n,m;
scanf("%d %d", &m ,&n );
int s[n];
s[0]=m;
int i=1;
int j=0;
int flag=0;
int count=1;
for(i=1;i<n;i++)
{
s[i]=(2*s[i-1])%n;
for(j=0;j<i;j++)
{
if(i==j)
{
continue;
}
if(s[i]==s[j])
{
flag=1;
}
}
if(flag)
{
break;
}
count++;
}
printf("%d", count);
return 0;
}
super awsm dude!!!!
ReplyDeleteThanks bro. All this is for my bros
Delete