牛客 E.Morse Code(思维)

题目链接:点击这里
在这里插入图片描述
在这里插入图片描述
长度为 2 2 4 4 种情况已经全部出现过,长度为 3 3 8 8 种情况也已经出现过,因此我们一定能够利用长度为 2 2 3 3 的字母去填充,因此答案就是 l e n / 2 len/2

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>

using namespace std;
typedef long long ll;
const int MOD = 10000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int maxn = 1010;
int a[maxn];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int t;
	string s;
	cin>>t;
	while(t--)
	{
		cin>>s;
		int len = s.length();
		cout<<len/2<<endl;
	}
	return 0;
}
发布了673 篇原创文章 · 获赞 103 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/qq_42815188/article/details/104055286