该题比较简单,只需要简单的for循环语句结合if即可得到答案
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <iomanip>
#include<cmath>
#include<cstring>
#include<cctype>
#include<queue>
using namespace std;
int main()
{
for (int i = 1; i < 10000; i++)
{
if (i % 5 == 1)
{
int n1 = i / 5;//计算自己的那一份
int s1 = i - 1 - n1;//计算下一个猴子看到的全部香蕉
if (s1%5==2)
{
int n2 = s1 / 5;//以下内容同上
int s2 = s1 - 2 - n2;;
if (s2 % 5 == 3)
{
int n3 = s2 / 5;
int s3 = s2 - 3 - n3;
if (s3 % 5 == 4)
{
int n4 = (s3 - 4) / 5;
int s4 = s3 - 4 - n4;
if (s4 % 5 == 0)
{
cout << i << endl;
}
}
}
}
}
}
return 0;
}