TLE求助
查看原帖
TLE求助
1395722
jushuo123楼主2025/1/3 18:22
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
string s;
ull l,cnt[114514],maxx;
int ans;
signed main(){
	ios::sync_with_stdio(false);
	cin>>s>>l;
	ull lll=s.size();
	if(lll>=l){
		cout<<ans;
		return 0;
	}
	for(ull i=0;i<lll;i++){
		cnt[s[i]]++;
		maxx=max(maxx,cnt[s[i]]);
	}
	while(lll<l){
		lll+=maxx;
		maxx*=2;
		++ans;
	}
	cout<<ans;
	return 0;
}
2025/1/3 18:22
加载中...