首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
基础学习课
实战项目课
求职辅导课
专栏&文章
竞赛
搜索
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
AI面试、笔试、校招、雇品
HR免费试用AI面试
最新面试提效必备
登录
/
注册
飞鸢泛惊鸿
获赞
30
粉丝
6
关注
6
看过 TA
11
山东管理学院
2029
算法工程师
IP属地:山东
暂未填写个人简介
私信
关注
拉黑
举报
举报
确定要拉黑飞鸢泛惊鸿吗?
发布(14)
评论
刷题
收藏
飞鸢泛惊鸿
关注TA,不错过内容更新
关注
昨天 14:22
山东管理学院 算法工程师
题解 | dd爱框框
import sys import array input=sys.stdin.readline n,x=0,0 nums=array.array('i', []) num=0 while True: s=sys.stdin.buffer.read() if not s:break for b in s: if 48 <= b <= 57: num = num * 10 + (b - 48) else: if not n: n=num num=0 continue if not x: x=num num=0 continue nums.append(num) num=0 ans_l...
0
点赞
评论
收藏
分享
04-20 12:41
山东管理学院 算法工程师
题解 | #字符串构造#
这道题写个pass都能过,应该是只检测有没有SATAN了 下面是正解(应该?) s=input() #找前缀下标,定位到最后一个字母 def find(s,tar): idx=-1 for c in tar: idx=s.find(c,idx+1) if idx==-1:return -1 return idx idx=find(s,"SA") if idx!=-1: if s.find("N",idx+1)!=-1: #有SAN print(s+"TA") else: #SA后面无N print(s[:idx+1]+"NTA"+s[idx+1:]) else: print(s+"SANTA"...
0
点赞
评论
收藏
分享
04-20 11:27
山东管理学院 算法工程师
题解 | 穷哈哈~
input() s=input() ans=0#全局最大值 curr=0#每部分最大值 for i,c in enumerate(s): if c=="a" or c=="h":#如果当前是a或者h if i and (s[i-1]=="a" or s[i-1]=="h") and s[i-1]!=s[i]:#当前不是第一个字符并且上一个是a或者h,并且是交替的 curr+=1#贡献值加1 else: curr=1#否则重置为一 ans=max(ans,curr)#计算最大值 print(ans)
0
点赞
评论
收藏
分享
04-19 12:08
山东管理学院 算法工程师
题解 | 小红的完全二叉树构造
n=int(input()) print(*list(range(2,n+1,2))+list(range(1,n+1,2))) 注意到构造序列 = 所有偶数(2,4,6,… 直到 ≤n)+ 所有奇数(1,3,5,… 直到 ≤n)
0
点赞
评论
收藏
分享
04-11 11:02
山东管理学院 算法工程师
题解 | 圆覆盖
import sys input = sys.stdin.readline def solve(): n,S=map(int,input().split()) point=[] for _ in range(n): x,y,v=map(int,input().split()) r2=x*x+y*y point.append((r2,v)) point.sort() total=0 for r2,v in point: total+=v if total>=S: print(r2**0.5) return print(-1) return solve() 读入数据,根据r方排序,当权值之和...
0
点赞
评论
收藏
分享
04-10 14:42
山东管理学院 算法工程师
题解 | 小红的图上加边
题目理解有一张无向图,共有 n 个点,每个点有一个权值 aᵢ。图中已经有 m 条边,我们要通过加边把它变成连通图。每次加边的代价是:这条边连接的两个连通块合并后,新的连通块中最大的节点权值。问:连通整个图的最小总代价是多少?思路分析假设我们一开始有 k 个连通块。每个连通块都有一个“代表值”,就是这个连通块中最大的节点权值(因为合并后的连通块最大权值会保留下来,成为下次合并的代价)。关键规律:每次合并两个连通块 A 和 B,代价是 max(最大权值(A), 最大权值(B))。为了让总代价最小,我们应该每次用最小的权值连通块去合并其他块吗? 不一定。 实际上,有一个更简单的思路: 假设所有连通块...
0
点赞
评论
收藏
分享
04-09 14:55
山东管理学院 算法工程师
题解 | 绿豆蛙的归宿
message=[[0,0] for _ in range(n+1)]#值,概率message[1][1]=1先设最开始概率为1message[v][1]+=curr_g*(1/n)message[v][0]+=(curr_value/curr_g+w)*(1/n)*curr_gprint("{:.2f}".format(round(message[-1][0]/message[-1][1],2))) import sys input = sys.stdin.readline n,m=map(int,input().split()) in_size=[0]*(n+1) ou...
0
点赞
评论
收藏
分享
04-08 11:42
山东管理学院 算法工程师
题解 | 抽卡
这是一个概率问题,需要计算在每个卡池都单抽一次的情况下,至少抽到一张想要的卡的概率。由于是概率计算,且需要输出模意义下的结果,我们需要用组合数学和模运算的知识来解决。先想简单情况举个例子:池子1:3 种卡,你想要 1 种 → 抽一次,抽到你想要的概率是 1/3池子2:4 种卡,你想要 1 种 → 概率 1/4那至少一张抽到的概率 = 1 - 一张都没抽到的概率一张都没抽到 = 池子1没抽到 * 池子2没抽到= (2/3) * (3/4) = 6/12 = 1/2所以至少一张抽到的概率 = 1 - 1/2 = 1/2变成数学式子设:分子 mol = ∏(aᵢ - bᵢ) ← 这个是“全都没抽到”...
0
点赞
评论
收藏
分享
04-05 22:55
山东管理学院 算法工程师
题解 | Kevin喜欢零(困难版本)
from typing import List, Optional from collections import deque, defaultdict, Counter import heapq import bisect import sys inf = float('inf') # inf=0x3f3f3f3f MOD = 10**9+7 # input=lambda:sys.stdin.readline()[:-1] input = sys.stdin.readline def cnt(a): cnt_5=0 cnt_2=0 while a%5==0: a//=5 cnt_5+=1 w...
0
点赞
评论
收藏
分享
03-30 11:34
山东管理学院 算法工程师
题解 | 小苯的ovo2.0
先全部改成o,然后二重循环枚举一个范围,将此范围改成v,然后计算取最大值同时可以在上一个答案大于本次计算答案时,退出循环 #include <iostream> #include <vector> #include <string> using namespace std; long long compute(const string& s, int n, int total_v) { int cnt_v = 0, cnt_o = 0; long long ans = 0; for (int i = 0; i < n; i++) { if (s...
0
点赞
评论
收藏
分享
03-09 11:01
山东管理学院 算法工程师
题解 | 小苯的蓄水池(hard)
import sys input=sys.stdin.readline print=sys.stdout.write def _join(u,v): u_p,v_p=_find(u),_find(v) if u_p<v_p:v_p,u_p=u_p,v_p if u_p==v_p:return False cnts[u_p]+=cnts[v_p] nums[u_p]+=nums[v_p] parent[v_p]=u_p return True def _find(p): root=p while root!=parent[root]: root=parent[root] while roo...
0
点赞
评论
收藏
分享
03-08 22:19
山东管理学院 算法工程师
题解 | 连分数
import sys input=sys.stdin.readline print=sys.stdout.write def compute(num,deno): integer=num//deno remain=num%deno if remain==0: return 0,str(num//deno) if remain==1: return 1,"{}+{}".format(integer,"1/"+str(deno)) tag,ans=compute(deno,remain) if tag: return 1,"{}+1/{{{}}}&...
0
点赞
评论
收藏
分享
02-23 15:05
山东管理学院 算法工程师
题解 | 小红统计区间(easy)
import sys input=sys.stdin.readline n,k=map(int,input().split()) nums=list(map(int,input().split())) n=len(nums) l=0 total=0 ans=0 for r in range(n): total+=nums[r] while l<n and total-nums[l]>=k: total-=nums[l] l+=1 if total>=k: ans+=l+1 print(ans) 不难看出,枚举右时间复杂度O(n)
0
点赞
评论
收藏
分享
02-09 01:13
山东管理学院 算法工程师
题解 | 小红的数组清空
from collections import Counter input() nums=list(map(int,input().split())) ans=0 prev_cnt=0 prev_key=-1 cnt=Counter(nums) for i in sorted(cnt.keys()): if prev_key+1!=i: prev_cnt=0 ans+=max(0,cnt[i]-prev_cnt) prev_key=i prev_cnt=cnt[i] print(ans) 1.统计每个数字出现的次数2.按顺序遍历3.计算代价
0
点赞
评论
收藏
分享
1
创作者周榜
更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务