![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++算法
月巴巴
还在摸索的学弱一枚 奋斗吧!
展开
-
四人过桥问题
问题:四人夜过桥,步行时间分别为 1、2、5、10 分钟,四人只有一台手电筒,一趟最多两人过桥,一趟过桥须持手电筒,时间以最慢者计,问 17 分钟内可否过桥,如何过桥?#include using namespace std;const int n = 4; //4个人const int size = 64;int position[n]; //表示每个人的状态原创 2015-04-09 00:05:54 · 720 阅读 · 2 评论 -
素数心得
素数思路 PS 可以从3开始每次加2进行判断构造素数数组 毕竟偶数都是合数1、正常暴力解法//从2到n进行一一判断bool fn(int i){ if(i==2) return true; for(int n=2;n<i;++n) { if(i%n==0) return原创 2016-08-09 23:08:01 · 412 阅读 · 0 评论