社区讨论

各位大神们帮帮忙,debug一下,谁能解决问题,救救孩子?

P1008[NOIP 1998 普及组] 三连击参与者 6已保存回复 7

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
7 条
当前快照
1 份
快照标识符
@lobwlnv9
此快照首次捕获于
2023/10/30 04:08
2 年前
此快照最后确认于
2024/07/24 12:47
2 年前
查看原帖
代码如下:
CPP
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int one, two, three;
    for (int a = 1; a <= 9; a++)
    { 
        for (int b = 1; b <= 9; b++)
        {
        	if (a == b)
			{
				continue;
			}
            for (int c = 1; c <= 9; c++)
            {
            	if (b == c || a == c)
				{
					continue;
				}
                one = a * 100 + b * 10 + c;
                for (int d = 1; d <= 9; d++)
                {
                	if (c == d || b == d || a == d)
					{
						continue;
					}
                    for (int e = 1; e <= 9; e++)
                    {
                		if (d == e || c == e || b == e || a == e)
						{
							continue;
						}
                        for (int f = 1; f <= 9; f++)
                        {
                        	if (e == f || d == f || c == f || b == f || a == f)
							{
								continue;
							}
                            two = d * 100 + e * 10 + f;
                            for (int g = 1; g <= 9; g++)
                            {
                            	if (f == g || e == g || d == g || c == g || b == g || a == g)
								{
									continue;
								}
                                for (int h = 1; h <= 9; h++)
                                {
                                	if (g == h || f == h || e == h || d == h || c == h || b == h || a == h)
                                	{
										continue;
									}
                                    for (int i = 1; i <= 9; i++)
                                    {
                                    	if (h == i || g == i || f == i || e == i || d == i || c == i || b == i || a == i)
										{
											continue;
										}
                                        three = g * 100 + h * 10 + i;
                                        if (one * 3 == two * 2 && two * 2 == three)
                                        {
                                            cout << one << ' ' << two << ' ' << three << endl;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}
谢大神们指点!!!谢谢!!!

回复

7 条回复,欢迎继续交流。

正在加载回复...