欢迎来到IllIIlll的主页
广告
整活部分
当一个人学完Python学C++时:
#import cstdio *
def main():
print("Hello,World!")
return 0似乎没问题
#include <cstdoi>
int man(){
scanf("Hello,World!\n");
retrun 0;
}bdfs
1.bdfs的定义
bfs(bomb first search,爆炸优先搜索)+dfs(death first search,死亡优先搜索)=bdfs(Baidu优先搜索)
2.bdfs的作用
可以用来炸程序。
3.bdfs的代码示饭(Python)
代码由AI生成
import collections
import random
def bdfs(graph, start, target, baidu_factor=0.5):
# 初始化队列和访问记录
queue = collections.deque()
queue.append([start])
visited = set([start])
# 百度特色:随机爆炸或死亡事件
explosion_chance = 0.1 * baidu_factor
death_chance = 0.1 * (1 - baidu_factor)
while queue:
# 随机决定是BFS风格(爆炸优先)还是DFS风格(死亡优先)
if random.random() < baidu_factor:
# BFS风格:从队列前端取出路径(广度优先)
path = queue.popleft()
print(f"爆炸优先: 探索 {path[-1]}")
else:
# DFS风格:从队列后端取出路径(深度优先)
path = queue.pop()
print(f"死亡优先: 探索 {path[-1]}")
node = path[-1]
# 随机爆炸事件:放弃当前路径
if random.random() < explosion_chance:
print(f"💥 节点 {node} 发生爆炸,路径中断!")
continue
# 随机死亡事件:放弃所有搜索
if random.random() < death_chance:
print(f"💀 搜索过程死亡,全部中断!")
return None
# 如果找到目标,返回路径
if node == target:
print("🎉 成功找到目标!")
return path
# 探索邻居节点
for neighbor in graph.get(node, []):
if neighbor not in visited:
visited.add(neighbor)
new_path = list(path)
new_path.append(neighbor)
queue.append(new_path)
# 百度特色:有时会随机推荐不相关的节点
if random.random() < 0.05: # 5%的概率推荐不相关节点
random_node = random.choice(list(graph.keys()))
if random_node not in visited and random_node != neighbor:
visited.add(random_node)
random_path = list(path)
random_path.append(random_node)
queue.append(random_path)
print(f"🔍 百度为您推荐了相关节点: {random_node}")
return None
# 示例图
graph = {
'A': ['B', 'C'],
'B': ['A', 'D', 'E'],
'C': ['A', 'F'],
'D': ['B'],
'E': ['B', 'F'],
'F': ['C', 'E', 'G'],
'G': ['F']
}
# 执行百度优先搜索
print("开始百度优先搜索 (BDFS):")
result = bdfs(graph, 'A', 'G', baidu_factor=0.6)
print(f"\n最终路径: {result}")壶关条件:这个值达到40
#include <bits/stdc++.h>
using namespace std;
const string n[]={"灰","红","橙","黄","绿","蓝","紫","黑"};
double s[]={0,1,2,3,4,6,8,10};
int main(){
int kkksc03[10]={};
double score = 0;
for (int i = 1;i <= 7;i ++){
cout << "你的" << n[i] << "题数:\n";
cin >> kkksc03[i];
score += kkksc03[i]*s[i];
}
cout << "你的咕值:\n";
int luogu;
cin >> luogu;
score += 10000/(500-luogu);
cout << "你的钩子等级:\n";
int lin_toto;
cin >> lin_toto;
if (lin_toto>0 && lin_toto<=10){
score += (4<<(lin_toto+2));
}
int chen_zhe;
cout << "你的等级分:\n";
cin >> chen_zhe;
score += chen_zhe/5.0;
printf("你的得分:%.2lf\n",score/(score+1000)*100);
return 0;
}