当前位置:网站首页>search--09
search--09
2022-08-10 12:06:00 【51CTO】
题目大概:
输入n组数据,Two four-digit prime numbers for each set of data.Let the first four-digit number change to the second four-digit number,Only one number can be changed per step,The changed number must also be a prime number,Ask at least a few steps to change can be successful.
思路:
用广度优先搜索.
Sift out all prime numbers first,方便判断,Then the four digits are changed one by one,Put the eligible numbers into the queue,until it becomes the second number,输出改变次数.
感想:
数据过多,Make a class of data into a structure,This makes it easier to queue,And if there are multiple queues,内存会不够.
代码:
边栏推荐
- 【LeetCode】640. 求解方程
- 力扣练习——64 最长和谐子序列
- LeetCode 82. Remove Duplicate Elements in Sorted List II
- Network sockets (UDP and TCP programming)
- 可视化服务编排在金融APP中的实践
- mpf6_Time Series Data_quandl_correct kernel PCA_AIC_BIC_trend_log_return_seasonal_decompose_sARIMAx_ADFull
- ViT结构详解(附pytorch代码)
- HDU 6040 Hints of sd0061 (技巧)
- Threshold-based filtering buffer management scheme in a shared buffer packet switch论文核心部分
- 一文详解 implementation api embed
猜你喜欢
随机推荐
面试官:你们是如何保证接口的幂等性?
Go 事,Gopher 要学的数字类型,变量,常量,运算符 ,第2篇
个推数据资产管理经验 | 教你打造数据质量心电图,智能检测数据“心跳”异常
VSCode远程连接服务器报错:Could not establish connection to “xxxxxx”的可能错误原因及解决
Analysis of the implementation principle of UUID from the perspective of source code
HDU 4135:Co-prime (容斥原理)
LeetCode 138. 复制带随机指针的链表
Do self-media monthly income tens of thousands?Several self-media tools that bloggers are using
项目部署、
搜索--09
配置swagger
LeetCode 86. Delimited Linked List
苹果逆势扩大iPhone 14系列备货,总量或达9500万部
LeetCode50天刷题计划(Day 17—— 下一个序列(14.50-16.30)
codevs 2370 小机房的树 (LCA)
Where can I view the version record of WeChat applet submission review history?
mpf6_Time Series Data_quandl_correct kernel PCA_AIC_BIC_trend_log_return_seasonal_decompose_sARIMAx_ADFull
皕杰报表在传参乱码
10 个 Reduce 常用“奇技淫巧”
正则表达式常用示例