E. Median String

You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than tt.

Let's consider list of all strings consisting of exactly kk lowercase Latin letters, lexicographically not less than ss and not greater than tt(including ss and tt) in lexicographical order. For example, for k=2k=2, s=s="az" and t=t="bf" the list will be ["az", "ba", "bb", "bc", "bd", "be", "bf"].

Your task is to print the median (the middle element) of this list. For the example above this will be "bc".

It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.

Input

The first line of the input contains one integer kk (1≤k≤2⋅1051≤k≤2⋅105) — the length of strings.

The second line of the input contains one string ss consisting of exactly kk lowercase Latin letters.

The third line of the input contains one string tt consisting of exactly kk lowercase Latin letters.

It is guaranteed that ss is lexicographically less than tt.

It is guaranteed that there is an odd number of strings lexicographically not less than ss and not greater than tt.

Output

Print one string consisting exactly of kk lowercase Latin letters — the median (the middle element) of list of strings of length kklexicographically not less than ss and not greater than tt.

Examples

input

Copy

2
az
bf

output

Copy

bc

input

Copy

5
afogk
asdji

output

Copy

alvuw

input

Copy

6
nijfvj
tvqhwp

output

Copy

qoztvz

题意:给你两个长度为n的字符串然后求位于它两中间的字符串

思路:把字母转换成26进制情况然后模拟加法,和除法(准确的说是除二)。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#define LL long long 

using namespace std;
const int maxn=2e5+100;

char s[maxn],t[maxn];
int a[maxn],b[maxn];
int ans[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	
	for(int i=1;i<=n;i++)
	{
		a[i]=s[i]-'a';
		b[i]=t[i]-'a';
	}
	
	for(int i=n;i>=1;i--)
	{
		//cout<<a[i]<<" "<<b[i]<<endl;
		a[i]+=b[i];
		if(a[i]>=26)
		{
			a[i-1]+=a[i]/26;
			a[i]%=26;
		}
		//cout<<a[i]<<" ";
	}
	//cout<<a[0];
	for(int i=0;i<=n;i++)
	{
		ans[i]=a[i]/2;
		//cout<<ans[i]<<" "<<a[i]<<endl;
		int mod=a[i]%2;
		a[i+1]+=mod*26;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%c",ans[i]+'a');
	}
	printf("\n");
	return 0;
}

 

# DBSCAN from sklearn.cluster import DBSCAN import pandas as pd from sklearn.preprocessing import StandardScaler from sklearn.metrics import silhouette_score import matplotlib.pyplot as plt train_data = pd.read_csv('train.csv') test_data = pd.read_csv('test.csv') features = ['Annual Income', 'Years in current job', 'Tax Liens', 'Number of Open Accounts', 'Maximum Open Credit', 'Number of Credit Problems', 'Bankruptcies', 'Current Loan Amount', 'Current Credit Balance', 'Monthly Debt', 'Credit Score'] train_data[features] = train_data[features].fillna(train_data[features].mean()) test_data[features] = test_data[features].fillna(test_data[features].mean()) # 标准化 scaler = StandardScaler() train_scaled = scaler.fit_transform(train_data[features]) test_scaled = scaler.transform(test_data[features]) # DBSCAN聚类 dbscan = DBSCAN(eps=0.5, min_samples=5) dbscan.fit(train_scaled) # 将DBSCAN的聚类结果添加到DataFrame中 train_data['DBSCAN_Cluster'] = dbscan.labels_ # Agglomerative Clustering agg = AgglomerativeClustering(n_clusters=3) agg.fit(train_scaled) # 将Agglomerative Clustering的聚类结果添加到DataFrame中 train_data['Agglomerative_Cluster'] = agg.labels_ # Gaussian Mixture Model gmm = GaussianMixture(n_components=3) gmm.fit(train_scaled) # 将Gaussian Mixture Model的聚类结果添加到DataFrame中 train_data['GMM_Cluster'] = gmm.predict(train_scaled) # 可视化 plt.figure(figsize=(18, 6)) # DBSCAN聚类结果 plt.subplot(131) plt.scatter(train_data['Credit Score'], train_data['Annual Inc'], c=train_data['DBSCAN_Cluster'], cmap='viridis') plt.xlabel('Credit Score') plt.ylabel('Annual Income') plt.title('DBSCAN Clustering Results') # Agglomerative Clustering结果 plt.subplot(132) plt.scatter(train_data['Credit Score'], train_data['Annual Inc'], c=train_data['Agglomerative_Cluster'], cmap='viridis') plt.xlabel('Credit Score') plt.ylabel('Annual Income') plt.title('Agglomerative Clustering Results') # Gaussian Mixture Model结果 plt.subplot(133) plt.scatter(train_data['Credit Score'], train_data['Annual Inc'], c=train_data['GMM_Cluster'], cmap='viridis') plt.xlabel('Credit Score') plt.ylabel('Annual Income') plt.title('Gaussian Mixture Model Results') plt.tight_layout() plt.show()ValueError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_47176\2994685919.py in ?() ---> 17 # DBSCAN 18 from sklearn.cluster import DBSCAN 19 import pandas as pd 20 from sklearn.preprocessing import StandardScaler e:\Anaconda-python\envs\is6423new\lib\site-packages\sklearn\utils\_set_output.py in ?(self, X, *args, **kwargs) 138 @wraps(f) 139 def wrapped(self, X, *args, **kwargs): --> 140 data_to_wrap = f(self, X, *args, **kwargs) 141 if isinstance(data_to_wrap, tuple): 142 # only wrap the first output for cross decomposition 143 return_tuple = ( e:\Anaconda-python\envs\is6423new\lib\site-packages\sklearn\base.py in ?(self, X, y, **fit_params) 911 # non-optimized default implementation; override when a better 912 # method is possible for a given clustering algorithm 913 if y is None: 914 # fit method of arity 1 (unsupervised transformation) --> 915 return self.fit(X, **fit_params).transform(X) 916 else: 917 # fit method of arity 2 (supervised transformation) 918 return self.fit(X, y, **fit_params).transform(X) ... e:\Anaconda-python\envs\is6423new\lib\site-packages\pandas\core\generic.py in ?(self, dtype) 2069 def __array__(self, dtype: npt.DTypeLike | None = None) -> np.ndarray: -> 2070 return np.asarray(self._values, dtype=dtype) ValueError: could not convert string to float: '10+ years' 怎么改
最新发布
03-08
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值