【美团杯2020】114514 解题报告

原题地址:http://uoj.ac/contest/53/problem/529

这题说实话我觉得有点玄学。我的方法是从左到右贪心,优先给每个4分配两个1,1不够的时候就再取出来。虽然我也意识到思路有问题,但是一直找不到反例,所以无从下手,最后死磕这道题也没搞出来。这里给出我的错误代码:

#include<cstdio>
#include<iostream>
using namespace std;
	int t,cnt;
	char a[600006];
	int s[600006][7];
	int que[600006];
int main()
{
   
	scanf("%d\n",&t);
	while (t --)
	{
   
		cnt = 0;
		string t;
		getline(cin,t);
		for (int i = 0;i < t.size();i ++)
			if (t[i] == '1' || t[i] == '4' || t[i] == '5')
				a[++cnt] = t[i];
		int tot = 0;
		int tot2 = 0;
		int tot3 = 0;
		int tot4 = 0;
		int tot5 = 0;
		int tot6 = 0;
		int head = 1;
		int tail = 0;
		for (int i = 1;i <= cnt;i ++)
			if (a[i] == '1'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值