随笔分类 - 一些些算法
摘要:转自: http://www.cnblogs.com/A-S-KirigiriKyoko/articles/6034572.html 我们知道当一个数为素数的时候,它的倍数肯定不是素数。所以我们可以从2开始通过乘积筛掉所有的合数。 将所有合数标记,保证不被重复筛除,时间复杂度为O(n)。 if(i
阅读全文
摘要:凑算式 B DEF A + + = 10 C GHI (如果显示有问题,可以参见【图1.jpg】) 这个算式中A~I代表1~9的数字,不同的字母代表不同的数字。 比如: 6+8/3+952/714 就是一种解法, 5+3/1+972/486 是另一种解法。 这个算式一共有多少种解法? 注意:你提交应
阅读全文
摘要:Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0
阅读全文
摘要:Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 10
阅读全文
摘要:DFS主要在于参数的改变; 样例输入: n=4 //给定n个数字 a={1,2,4,7} //输入n个数据 k=15 //目标数字 样例输出: No 题意: 给定的数字在不重复使用的前提下能否达到目标,能输出Yes,否输出No#include<algorithm> #include<iostream
阅读全文
摘要:每瓶啤酒2元,2个空酒瓶或4个瓶盖可换1瓶啤酒。10元最多可喝多少瓶啤酒? #include<algorithm> #include<iostream> using namespace std; int dfs(int p, int g, int ans) { if(p < 2 && g < 4)
阅读全文
摘要:Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangula
阅读全文
摘要:Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00
阅读全文
摘要:迷宫问题 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,
阅读全文
摘要:Dungeon Master Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or m
阅读全文

浙公网安备 33010602011771号