GPLT 团体程序设计天梯赛 2023年 - 正式赛 125分摆烂代码

GPLT 团体程序设计天梯赛 2023年 - 正式赛(13点30开始)

摆摆摆,咕咕咕

L1-1 最好的文档

print("Good code is its own best documentation.")

L1-2 什么是机器学习

#include 
using namespace std;
int main()
{
	int a =0, b = 0;
	cin >> a >> b;
	int c = a + b;
	cout << c - 16 << endl; 
	cout << c - 3 << endl;
	cout << c - 1 << endl;
	cout << c << endl;
	return 0;	
} 

L1-3 程序员买包子

#include 
#include 
using namespace std;
int main()
{
	int n = 0 , m = 0, k = 0;
	string x;
	cin >> n >> x >> m >> k;
	if (n == k) cout << "mei you mai " << x << " de";
	else if (m == k) cout << "kan dao le mai " << x << " de";
	else cout << "wang le zhao mai " << x << " de";
	return 0;	
} 

L1-4 进化论

#include 
using namespace std;
int main()
{
	int t =0 ;
	cin >> t;
	while (t--)
	{
		int x = 0, y = 0, z = 0;
		cin >> x >> y >> z;
		if (x * y == z) cout << "Lv Yan\n";
		else if (x + y == z) cout << "Tu Dou\n";
		else cout << "zhe du shi sha ya!\n"; 
	}
	return 0;
}

L1-5 猜帽子游戏

#include 
using namespace std;
const int N = 110;
int main()
{
	int n = 0, m[N] = {0};
	cin >> n;
	for (int i = 0; i < n; i++) cin >> m[i];
	int k = 0;
	cin >> k;
	while(k--)
	{
		int tmp = 0, sum = 0;
		bool flag = true;
		for(int i = 0; i < n; i++)
		{
			cin >> tmp;
			if (tmp == 0) continue;
			else if (tmp == m[i]) sum++;
			else flag = false;
		}
		if (flag && sum) cout << "Da Jiang!!!\n";
		else cout << "Ai Ya\n"; 
	} 
	return 0;
}

L1-6 剪切粘贴

#include 
#include 
using namespace std;
int main()
{
	string str;
	cin >> str;
	int n = 0;
	cin >> n;
	while (n--)
	{
		int a = 0, b = 0, len = 0;
		string x, y, tmp;
		cin >> a >> b >> x >> y; 
		a--, b--, len = x.size();
		
		tmp = str.substr(a, b - a + 1);
		str.erase(a, b - a + 1);
		
		string sum = x + y; 

		if(str.find(sum) != -1) str.insert((str.find(sum) + len), tmp);
		else str.insert((str.size()), tmp);  
	}
	cout << str;
	return 0;
}

L1-7 分寝室(19/20)

#include 
#include 
using namespace std;
int main()
{
	int a = 0, b = 0, n = 0, sum = 0, x = 0, y = 0, z = 100000;
	cin >> a >> b >> n;
	for (int i = 2; i < b; i++)
	{
		if (a % i == 0)
		{
			int p = a / i, q = n - p;
			if(p >= 2 && q >= 2 && b % q == 0)
			{
				sum++;
				int tmp = abs(p - q);
				if (tmp <= z) x = p, y = q;
//					if(sum) cout << "00000 " << x << " " << y << endl;
			}
		}
	}
	
	if(sum) cout << x << " " << y;
	else cout << "No Solution";
	return 0;
}

L1-8 谁管谁叫爹

#include 
using namespace std;
int func(long long n)
{
	int ans = 0;
	while (n)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
int main()
{
	int n = 0;
	cin >> n;
	while (n--) 
	{
		long long A = 0, B = 0;
		cin >> A >> B;
		int a = func(A), b = func(B), sum = a + b;
		if (A % b == 0 && B % a == 0 || A % b != 0 && B % a != 0) cout << (A > B ? "A\n" : "B\n");
		else if(A % b == 0 ) cout << "A\n";
		else if(B % a == 0 ) cout << "B\n";
	} 
	return 0;
}

L2-1 堆宝塔(24/25)

#include 
#include 
using namespace std;
int main()
{
	list<int>A;
	list<int>B;
	int n = 0, max = 0, sum = 0;
	cin >> n;
	while(n--)
	{
		int k = 0;
		cin >> k;
		if (A.empty() == 1 || k < A.back()) A.push_back(k);
		else
		{
			if (B.empty() == 1 || k > B.back()) B.push_back(k);
			else
			{
				max = max > A.size() ? max : A.size();
//				cout << max << " "<<  A.size() << endl;
				sum++;
				A.clear();
				while(k < B.back())
				{
					int tmp = B.back();
					B.pop_back();
					A.push_back(tmp);
				}
				A.push_back(k);
			}
		}
	}
	if (A.empty() != 1)
	{
		sum++;
		while(B.empty() != 1 && A.back() < B.back())
		{
			int tmp = B.back();
			B.pop_back();
			A.push_back(tmp);
		}
	} 
	if (B.empty() != 1) sum++;
	cout << sum << " " << max;
	return 0;
}

锦标赛(2/25)

print("No Solution")

寻宝图(2/25)

print("0 0")

你可能感兴趣的:(2022GPLT,c++,算法)