-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path305.c
68 lines (65 loc) · 1.07 KB
/
305.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
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
#include<string.h>
int main()
{
int n,a[107],i,m,next,count=0,temp,flag=0,n1;
scanf("%d",&n);
while(n!=0)
{
if(n==1)
m=2;
else{
n1=n*2;
memset(a,0,sizeof(a));
m=n+1; next=m;
count=1;
a[m]=1;
while(1){
memset(a,0,sizeof(a));
next=1;
flag=0;
temp=0;
while(temp<m)
{
temp++;
if(temp==m)
break;
next=(next==n1-1?(next+1):(next+1)%n1);
}
a[next]=1;
while(1){
temp=0;
next=(next==n1-1?(next+1):(next+1)%n1);
while(temp<m)
{
if(a[next]!=1)
{
temp++;
}
if(temp==m)
break;
next=(next==n1-1?(next+1):(next+1)%n1);
}
a[next]=1;
if(next<=n){
break;
}
for(i=n+1;i<=n1;i++)
if(a[i]==0)
break;
if(i==n1+1){
flag=1;
break;
}
}
if(flag==1)
break;
else
m++;
}
}
printf("%d\n",m);
scanf("%d",&n);
}
return 0;
}