
蓝桥寒假训练
AllenSeaho
这个作者很懒,什么都没留下…
展开
-
动态规划,3n+1问题
动态规划,3n+1问题[问题描述]考虑如下的序列生成算法:从整数 n 开始,如果 n 是偶数,把它除以 2;如果 n 是奇数,把它乘 3 加1。用新得到的值重复上述步骤,直到 n = 1 时停止。例如,n = 22 时该算法生成的序列是:22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1人们猜想(没有得到证明)对于任意整数 n,该算法总能终止于 n = 1...原创 2019-02-07 20:32:10 · 467 阅读 · 0 评论 -
蓝桥每周练二 扫雷问题(坐标的移动)
Minesweeper (扫雷)[问题描述]Have you ever played Minesweeper? It’s a cute little game which comes within a certain OperatingSystem which name we can’t really remember. Well, the goal of the game is to fi...原创 2019-02-08 09:53:29 · 378 阅读 · 0 评论 -
买橘子
【题目】小明去附近的水果店买橙子,水果商贩只提供整袋购买,有每袋6个和每袋8个的包装(包装不可拆分)。可是小明只想购买恰好n个橙子,并且尽量少的袋数方便携带。如果不能购买恰好n个橙子,小明将不会购买。【输入】购买的橙子数【输出】袋数,不能购买-1【思路】动态规划,i个橙子最少要DP[i]个袋子1. 先将DP[i]置-12. 若i<6或者i为奇数,直接判断不会购买3. 如果i-6...原创 2019-02-11 11:40:56 · 546 阅读 · 0 评论 -
蓝桥杯 摆花 DP
/*DP[i][j]表示第i种时摆了j盆有多少种摆法#include <iostream>#include<string.h>using namespace std;int main(){ int n,m,sum=0; cin>>n>>m; int a[n+1]; for(int i=1;i<n...原创 2019-03-07 19:56:31 · 398 阅读 · 0 评论 -
jungle roads
/*1.简单的krusal2.字符转数字 3.结构体排序4.感觉结构体还是比pair好用*/#include <iostream>#include<vector>#include<utility>#include<algorithm>#include<stdio.h>using namespace std;#de...原创 2019-03-23 10:09:14 · 155 阅读 · 0 评论