-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path151.c
57 lines (55 loc) · 920 Bytes
/
151.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<stdio.h>
#include<string.h>
int main()
{
int n,a[107],i,m,next,count=0,temp,flag=0;
scanf("%d",&n);
while(n!=0)
{
if(n==13)
m=1;
else{
memset(a,0,sizeof(a));
m=1; next=1;
count=1;
a[1]=1;
while(1){
memset(a,0,sizeof(a));
next=1;
flag=0;
a[1]=1;
while(1){
temp=0;
next=(next==n-1?(next+1):(next+1)%n);
while(temp<m)
{
if(a[next]!=1)
{
temp++;
}
if(temp==m)
break;
next=(next==n-1?(next+1):(next+1)%n);
}
a[next]=1;
for(i=1;i<=n;i++)
if(i!=13&&a[i]==0)
break;
if(i==n+1){
flag=1;
break;
}
if(next==13)
break;
}
if(flag==1)
break;
else
m++;
}
}
printf("%d\n",m);
scanf("%d",&n);
}
return 0;
}