看下这个对不对。。
#include
#include
int main()
{
int n, m, k, perfect, bad, colourful, smooth, exturn, turn, i, p, q;
scanf("%d %d %d", &n, &m, &k);
if (k <= m&&k <= n)
{
printf("perfect=%d bad=0 colourful=0 smooth=0", k);
}
else
{
perfect = colourful = smooth = bad = 0;
for (i = 1; i <= k; ++i)
{
int has_color, has_smooth;
has_color = i > n && ((i - 1) % n == 0);
has_smooth = i > m && ((i - 1) % m == 0);
if (has_color && has_smooth)
++perfect;
else if (has_color && !has_smooth)
++colourful;
else if (!has_color && has_smooth)
++smooth;
else
++bad;
}
printf("perfect=%d bad=%d colourful=%d smooth=%d", perfect, bad, colourful, smooth);
}
/*
else
{
turn = (n + 1)*(m + 1);
i = 1;
while (i <= (n + 1) && i <= (m + 1))
{
p = (n + 1) % i;
q = (m + 1) % i;
if (p == 0 && q == 0)
{
turn = turn / i;
break;
}
else i++;
}
bad = floor(k / turn);
colourful = floor(k / (m + 1)) - bad;
smooth = floor(k / (n + 1)) - bad;
perfect = k - bad - colourful - smooth;
printf("perfect=%d bad=%d colourful=%d smooth=%d", perfect, bad, colourful, smooth);
return 0;
}*/
}
//把17改成k 一开始写错了