五人分鱼问题

abcde五人打渔,打完睡觉,a先醒来,扔掉1条鱼,把剩下的分成5分,拿一份走了;
b再醒来,也扔掉1条,把剩下的分成5份,拿一份走了;
然后cde都按上面的方法取鱼。
问他们一共打了多少条鱼,写程序和算法

int judge(int n)
{
    int k = n;
    for(int i = 0;i < 5;i++){
        if((k-1)%5 == 0)
            k=(k-1)/5*4;
        else
            return -1;
    }
    return 0;
}

void getfishes()
{
    for(int i = 0; i < 9999;i++)
        if(!judge(i))
            cout<<i<<" fishes
"<<endl;
}
原文地址:https://www.cnblogs.com/xiaoerhei/p/3679216.html