#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, m;
int c = 0;
scanf("%d %d", &n, &m);
int count = n;
int sum = 0;
int a[n];
for(int i = 0;i < n; i++)
{
a[i] = 1;
}
while( count > 1)
{
if(a[c] != 0)
{
sum++;
if(sum == m)
{
a[c] = 0;
count--;
sum = 0;
}
}
c = ( c + 1) % n;
}
for( int j = 0; j< n; j++)
{
if(a[j] != 0)
{
printf("monkey king is: %d\n", j + 1);
}
}
return 0;
}
Time Limit: 1 Sec Memory Limit: 128 MB
Total Submissions: 1803 Accepted: 762 Creator: admin
Problem Desc