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

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

摆摆摆,咕咕咕

L1-1 最好的文档

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

L1-2 什么是机器学习

#include <iostream>
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 <iostream>
#include <string>
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 <iostream>
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 <iostream>
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 <iostream>
#include <string>
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 <iostream>
#include <cmath>
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 <iostream>
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 <iostream>
#include <list>
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")
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值