-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcards.c
More file actions
43 lines (39 loc) · 670 Bytes
/
cards.c
File metadata and controls
43 lines (39 loc) · 670 Bytes
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
#include "stdio.h"
int isprime(int n)
{
if(n==1)
return 0;
for(int i=2; i*i<=n; i++)
{
if(n%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
int n;
char s[50];
while(scanf("%d %s", &n, s))
{
for(int i=0; s[i]; i++)
{
if(s[i]=='R')
{
while(!isprime(i+1))
i++;
printf("%d ", i+1);
}
else
{
while(isprime(i+1))
i++;
printf("%d ", i+1);
}
}
puts("");
}
return 0;
}