-
Notifications
You must be signed in to change notification settings - Fork 48
/
1030.c
43 lines (28 loc) · 784 Bytes
/
1030.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
@autor: Malbolge;
@data: 10/12/2018;
@nome: A Lenda de Flavious Josephus;
*/
#include <stdio.h>
unsigned short recorrencia(unsigned short qtsSoldados, unsigned short qtsPulos);
void main ()
{
unsigned short casos;
unsigned short qtsInstancias;
unsigned short qtsSoldados, qtsPulos;
scanf("%hu", &casos);
qtsInstancias = 0;
while (casos--)
{
scanf("%hu %hu", &qtsSoldados, &qtsPulos);
printf("Case %hu: %hu\n", ++qtsInstancias, recorrencia(qtsSoldados, qtsPulos) + 1);
}
}
unsigned short recorrencia(unsigned short qtsSoldados, unsigned short qtsPulos)
{
unsigned short i, retorno;
retorno = 0;
for (i = 2; i <= qtsSoldados; i++)
retorno = (retorno + qtsPulos) % i;
return retorno;
}