53(2023.12.26)(烤鸡,三连击)

53(2023.12.26)(烤鸡,三连击)_第1张图片

#include
using namespace std;
#include
int arr[20000]={};
int main()
{
	int n,h;
	cin>>n>>h;
	int number;
	for(int i=0;i=0;i--)
	 {
	 	sum+=arr[i];
	 	times++;
	 	if(sum>=h)
	 	{
	 		i=-1;
		 }
	 }
	 cout<

53(2023.12.26)(烤鸡,三连击)_第2张图片

#include
using namespace std;
#include
int main()
{
	int n;
	cin>>n;
	if(n>30||n<10)
	{
	cout<<0<v;
	for(int a=0;a<=3;a++)
	{
		for(int b=0;b<=3;b++)
	{
		for(int c=0;c<=3;c++)
	{
		for(int d=0;d<=3;d++)
	{
		for(int e=0;e<=3;e++)
	{
		for(int f=0;f<=3;f++)
	{
		for(int g=0;g<=3;g++)
	{
		for(int h=0;h<=3;h++)
	{
		for(int i=0;i<=3;i++)
	{
		for(int j=0;j<=3;j++)
	{
		
		if(a+b+c+d+e+f+g+h+i+j==n)
		{
			times++
			/*cout<::iterator it=v.begin();it!=v.end();it++)
	{
		times2++
		if(times2==10)
		{
			times2=0;
			cout<<*it<
#define _CRT_SECURE_NO_WARNINGS 1
#include
using namespace std;
#include
#include
int main()
{
	int n;
	cin >> n;
	if (n > 30 || n < 10)
	{
		cout << 0 << endl;
		return  0;
	}
	int times = 0;
	string str;
	str.resize(10);
	vectorv;
	for (int a = 1;a <= 3;a++)
	{
		for (int b = 1;b <= 3;b++)
		{
			for (int c = 1;c <= 3;c++)
			{
				for (int d = 1;d <= 3;d++)
				{
					for (int e = 1;e <= 3;e++)
					{
						for (int f = 1;f <= 3;f++)
						{
							for (int g = 1;g <= 3;g++)
							{
								for (int h = 1;h <= 3;h++)
								{
									for (int i = 1;i <= 3;i++)
									{
										for (int j = 1;j <= 3;j++)
										{
											if (a + b + c + d + e + f + g + h + i + j == n)
											{
												times++;
												v.push_back(a);
												v.push_back(b);
												v.push_back(c);
												v.push_back(d);
												v.push_back(e);
												v.push_back(f);
												v.push_back(g);
												v.push_back(h);
												v.push_back(i);
												v.push_back(j);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << times << endl;
	int flag = 0;
	for (vector::iterator it = v.begin();it != v.end();it++)
	{
		flag++;
		if (flag == 10)
		{
			flag = 0;
			cout << *it << endl;
		}
		else
		{
			cout << *it << " ";
		}
	}
	system("pause");
	return 0;
}

53(2023.12.26)(烤鸡,三连击)_第3张图片

#include
#include
using namespace std;
int arr[9] = {};
bool test(int a, int b, int c)
{
	arr[0] = a / 100;
	arr[1] = (a / 10) - ((a / 100) * 10);
	arr[2] = a % 10;
	arr[3] = b / 100;
	arr[4] = (b / 10) - ((b / 100) * 10);
	arr[5] = b % 10;
	arr[6] = c / 100;
	arr[7] = (c / 10) - ((c / 100) * 10);
	arr[8] = c % 10;
	/*for (int i = 0;i < 9;i++)
	{
		cout << arr[i] << ' ';
	}*/
	sort(arr, arr + 9);
	for (int i = 0;i < 9;i++)
	{
		if (arr[i] != i + 1)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	//cout<> a >> b >> c;
	int flag = 0;
	for (int i = 100;i < 350;i++)
	{
		for (int j = i;j < 999;j++)		//a:b:c
		{								//i:j:z
			for (int z = j;z < 999;z++)
			{
				
					if (((a * j) == (b * i)) && ((b * z) == (c * j)) && (a * z) == (c * i))
					{
						if (test(i, j, z))
						{
							flag = 1;
							cout << i << ' ' << j << ' ' << z << ' ' << endl;
						}
					}
			}
		}
	}
	if (flag == 0)
	{
		cout << "No!!!" << endl;
	}
	system("pause");
	return 0;
}

 

你可能感兴趣的:(算法,数据结构)