当前位置:网站首页>搜索--09
搜索--09
2022-08-10 11:13:00 【51CTO】
题目大概:
输入n组数据,每组数据两个四位素数。让第一个四位数变到第二个四位数,每步只能改一个数,改后的数也必须是素数,问最少经过几步改变可以成功。
思路:
用广度优先搜索。
先把所有的素数筛出来,方便判断,然后四位数一位一位的改变,把符合条件的数放到队列中,直到变为第二个数,输出改变次数。
感想:
数据过多,就把一类数据做成一个结构体,这样方便进队列,而且如果分多个队列,内存会不够。
代码:
边栏推荐
- What are some useful performance testing tools recommended? Performance testing report charging standards
- 自媒体爆款标题怎么写?手把手教你写热门标题
- LeetCode 25. K 个一组翻转链表
- SMIC CIM localization project suspended?Rising software: not shut down, changed to remote development!
- Network sockets (UDP and TCP programming)
- 力扣练习——63 找到字符串中所有字母异位词
- LeetCode 92. 反转链表 II
- 基于UiAutomator2+PageObject模式开展APP自动化测试实战
- 配置druid数据源「建议收藏」
- gpu-admission 源码分析
猜你喜欢
Go 事,Gopher 要学的数字类型,变量,常量,运算符 ,第2篇
Analysis of the implementation principle of UUID from the perspective of source code
可视化服务编排在金融APP中的实践
mpf6_Time Series Data_quandl_更正kernel PCA_AIC_BIC_trend_log_return_seasonal_decompose_sARIMAx_ADFull
皕杰报表在传参乱码
推荐6个自媒体领域,轻松易上手
A little self-deprecating deconstruction about farmers "code"
实现内网穿透的最佳解决方案(无实名认证,完全免费)
Nocalhost - Making development more efficient in the cloud-native era
Does your child lack self-discipline?Ape Counseling: Pay attention to "blank" in the schedule to give children more control
随机推荐
中芯CIM国产化项目暂停?上扬软件:未停摆,改为远程开发!
力扣练习——58 验证二叉搜索树
leetcode 823. Binary Trees With Factors(因子二叉树)
StoneDB 文档捉虫活动第一季
Clicking Exercise - 64 Longest Harmonic Subsequences
Cannot find symbol log because lombok is not found
LeetCode 138. Copy a linked list with random pointers
态路小课堂丨如何为CXP光模块选择光纤跳线?
LeetCode 146. LRU 缓存
Apple bucks the trend and expands iPhone 14 series stocking, with a total of 95 million units
嘉为蓝鲸荣获工信部“数字技术融合创新应用解决方案”
彩色图和深度图转点云
LeetCode50天刷题计划(Day 19—— 在排序数组中查找元素的第一个和最后一个位置(9.10-10.40)
配置druid数据源「建议收藏」
什么是幂等性?四种接口幂等性方案详解!
Since the media hot style title how to write?Taught you how to write the title
Samsung plans to start producing semiconductor components in Vietnam in 2023
力扣练习——56 寻找右区间
A little self-deprecating deconstruction about farmers "code"
LeetCode 19. 删除链表的倒数第 N 个结点