关于昨晚的CF Div.2 C
  • 板块学术版
  • 楼主Magpie64
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/4/21 11:00
  • 上次更新2023/10/23 17:56:09
查看原帖
关于昨晚的CF Div.2 C
393321
Magpie64楼主2023/4/21 11:00

RT,我用GNU C++20 (64)就能过,但是用GNU C++17或者GNU C++14连样例都对不上,有没有大佬知道是为啥/kk

代码如下

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100010,INF = 0x3f3f3f3f;
const double eps = 0.0001;
int T,n,ans;
string s;
int main(){
	cin>>T;
	while(T--){
		ans = INF;
		cin>>s;
		for(int i=0;i<26;i++){
			int cnt = 0,now = 0;
			for(int j=0;j<s.length();j++){
				if(s[j]-'a'==i){
					cnt = 0;
				}
				else cnt++;
				if(cnt) now = max(now,(int)(log(cnt)/log(2))+1);
			}
			ans = min(ans,now);
		}
		cout<<ans<<endl;
	}
}
2023/4/21 11:00
加载中...