Photolog
Back to list of problems
Power Crisis
151.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int num;
int nums[100];
void compute(void)
{
int i,j,k;
for(i=1; i<=num; i++) {
int last=1;
nums[1]=0;
for(j=2; j<=num; j++) {
nums[j]=1;
}
while(1) {
int done=1;
for(j=1; j<=num; j++) {
if (nums[j]) {
done=0;
break;
}
}
if (last==13) {
if (done) {
printf("%d\n", i);
return;
} else {
break;
}
}
for(k=0; k<i; k++) {
while(1) {
last++;
if (last>num) {
last=1;
}
if (nums[last]) {
break;
}
}
}
nums[last]=0;
}
}
printf("Ein?\n");
}
int
main(void)
{
while(fscanf(stdin, "%d", &num)==1) {
if (num==0) {
exit(0);
}
compute();
}
exit(0);
}









