typedeflonglong LL; constint maxn = 55; int a[maxn];
boolcheck(int n, int p){ for (int i = 0; i < p; ++i) { if (n % p == 1) { n = n / p * (p - 1); } else { returnfalse; } } return n % p == 0; }
intmain(){ int n; while (~scanf("%d", &n) && n >= 0) { printf("%d coconuts, ", n); bool ok = false; for (int i = sqrt(n) + 1; i > 1; --i) { if ((n - 1) % i == 0 && check(n, i)) { printf("%d people and 1 monkey\n", i); ok = true; break; } } if (!ok) { puts("no solution"); } } return0; }