A、B、C、D、E五人在某天夜里合伙去捕鱼,到第二天凌晨时都疲惫不堪,于是各自找地方睡觉。日上三竿,A第一个醒来,他将鱼分成五份,把多余的一条鱼扔掉,拿走自己的一份。B第二个醒来,也将鱼分成五份,把多余的一条鱼扔掉,拿走自己的一份。C、D、E依次醒来,也按同样的方法拿鱼。问他们合伙至少捕了多少条鱼?
1 class Program
2 {
3 static void Main(string[] args)
4 {
5 int x = 0;
6
7 while (true)
8 {
9 x++;
10 bool isRight = true;
11 int tempx = x;
12 for (int i = 0; i < 5; i++)
13 {
14 if ((tempx - 1) % 5 == 0)
15 tempx = (tempx - 1) / 5 * 4;
16 else
17 {
18 isRight = false;
19 break;
20 }
21 }
22
23 if (isRight)
24 {
25 Console.WriteLine("他们合伙自少要捕 " + x + " 条鱼");
26 break;
27 }
28 }
29 }
30 }
2 {
3 static void Main(string[] args)
4 {
5 int x = 0;
6
7 while (true)
8 {
9 x++;
10 bool isRight = true;
11 int tempx = x;
12 for (int i = 0; i < 5; i++)
13 {
14 if ((tempx - 1) % 5 == 0)
15 tempx = (tempx - 1) / 5 * 4;
16 else
17 {
18 isRight = false;
19 break;
20 }
21 }
22
23 if (isRight)
24 {
25 Console.WriteLine("他们合伙自少要捕 " + x + " 条鱼");
26 break;
27 }
28 }
29 }
30 }
浙公网安备 33010602011771号