【2022秋招笔试题总结】
阿里笔试(9月3号)
有两个长度为n的只由01组成的字符串A,B。每次可以选择一个区间([1,n])将A进行反转,最少经过多少次这样的操作才能将A变成B?
//看两个串是否相等,相等就不用变,不想等就要看要变的区间有几个
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
string a, b;
cin>>n>>a>>b;
int count = 0;
bool tmp = false;
for(int i=0; i<n; ++i){
if(a[i] != b[i]){
if(tmp == false){
//字符不等并且和上一个区间断开
tmp = true;
count += 1;
}
}
else if(tmp == true){
//字符相等,若区间没断开说明得断了
tmp = false;
}
}
cout<<count<<endl;
return 0;
}
三个数a,b,c(好像是正整数),找到满足条件的组数
a ≤ x 2 ≤ b a\le x^2\le b a≤x2≤b, a ≤ y 3 ≤ b a\le y^3\le b a≤y3≤b, ∣ x 2 − y 3 ∣ ≤ c |x^2-y^3|\le c ∣x2−y3∣≤c
//首先算出y的上下界,枚举y,带回去求x,看是否满足条件
//27开立方本来是3,万一变成3.000000001,那么ceil就是4
#include<iostream>
#include<cmath>
using namespace std;
const double eps = 1e-9;
int main(){
long long a, b, c;
cin >> a >> b >> c;
long long start_y = ceil(pow(a, 1.0/3)-eps);
long long end_y = floor(pow(b, 1.0/3)+eps);
long long ans = 0;
for(long long y=start_y; y<=end_y; ++y){
long long y_3 = y*y*y;
long long start_x = ceil(pow(y_3-c<=1?1:y_3-c

这篇博客总结了2022年秋季招聘的笔试题目,包括阿里和美团的笔试经历。在阿里笔试中,讨论了如何通过反转01字符串的操作来使两个字符串相等的最小次数问题,以及解决三元组(a, b, c)条件下的组合计数问题。在美团实习笔试中,涉及到了softmax函数的计算。"
17632443,1425852,Spring定时器cron配置问题解决,"['Spring框架', '定时任务', 'Cron', 'Quartz库']
1万+

被折叠的 条评论
为什么被折叠?



