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

2023-12-27 06:02:50

#include<iostream>
using namespace std;
#include<algorithm>
int arr[20000]={};
int main()
{
	int n,h;
	cin>>n>>h;
	int number;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&number);
		arr[i]=number;
	 } 
	 int times=0;
	 int sum=0;
	 sort(arr,arr+n);
	 for(int i=n-1;i>=0;i--)
	 {
	 	sum+=arr[i];
	 	times++;
	 	if(sum>=h)
	 	{
	 		i=-1;
		 }
	 }
	 cout<<times<<endl;
	system("pause");
	return 0;
}

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

#include<iostream>
#include<algorithm>
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<<test(123,456,789)<<endl;
	int a, b, c;
	cin >> 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;
}

?

文章来源:https://blog.csdn.net/weixin_72770922/article/details/135185053
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。