-
-
Save jen6/8c911f22f4b9e95492ab4077e450dd6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
int main() { | |
int m, n; | |
scanf("%d %d" , &n, &m); | |
int arr[1000] = {0, }; | |
//1234567 | |
/* | |
12 4567 3 | |
12 45 7 6 | |
1 45 7 2 m*i - n | |
1 45 7 | |
*/ | |
int cnt = 1; | |
int idx = 1; | |
while(cnt != n) | |
{ | |
int i = 1; | |
while(i < m) | |
{ | |
if(idx > n) | |
{ | |
idx = 1; | |
} | |
if(!arr[idx]) | |
{ | |
i++; | |
idx++; | |
// printf("i : %di\n", i); | |
} | |
else | |
{ | |
idx++; | |
cnt++; | |
if(cnt == n) | |
break; | |
} | |
} | |
if(cnt != n) | |
printf("%d, ",idx); | |
arr[idx] = 1; | |
cnt = 1; | |
while(arr[idx]) | |
{ | |
idx++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment