题目:http://codeforces.com/problemset/problem/198/B Jumping on Walls time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya plays a computer game with ninjas. At this stage Vasya's ninja shou…
Jumping on Walls CodeForces - 198B 应该是一个隐式图的bfs,或者叫dp. 先是一个TLE的O(nklogn) #include<cstdio> #include<set> using namespace std; typedef pair<bool,int> P; ]; P t; ][]; int n,k,ii; int main() { int i,num,hei; scanf("%d%d",&n,&am…
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1621\(n\)头奶牛,刚开始在一起,每次分成\(x\)和\(x+m\)两部分,直到不能再分,问最后一共有几部分. 分析 可以知道当前奶牛数\(n=x+x+m\),所以可以继续分的必要条件是\(n-m>=2\),然后dfs就好了... 对于大数据,\(m=1000\)和\(m=1\)并没有什么区别,所以可以认为搜索时候一直是二分的,所以有\(log_2^n\)层,最下面一层有\(2^{log_…
一道大水题 时间限制: C/C++ 2000ms; Java 4000ms 内存限制: 65535KB 通过次数: 44 总提交次数: 1020 问题描述 Dr. Pan作为上兰帝国ACM的总负责人,对队员的队员的训练也是日常关心,他要求每周要有一位队员出一道题目.不知过了多少年,终于轮到Shiyiliang出题了,他费尽脑汁,终于出了一道大水题 给定一个偶数n,n的取值范围为[-1e18,1e18],要求一对整数x,y满足以下条件: 1.x*y==n 2.x与n必须同号,即如果n>0则x>0…
题目链接:http://poj.org/problem?id=3984 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表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线. Input 一个5 × 5的二维数组,表示一个迷宫.数据保证有…
快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着循环一次,统计出代码中的minnum和maxnum即可,注意最后一定要输出'\n',不然第三个测试会显示PE,格式错误. #include <iostream> #include <cstdio> #include <algorithm> #include <map&…
如题,大水题...贴个代码完事,就这么任性~~ #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #define INF 0x3f3f3f3f using namespace std; /* 求满足下面的最大的E: 恰好有E个天的行程都大于E miles 从小到大排序,倒着循环一遍,直到最小值<=天数为止,此时的天数-1即为答案. */ +; i…
BFS 简单题套路 1. 遇到迷宫之类的简单题,有什么行走方向的,先写下面的 声明 ; struct Status { int r, c; Status(, ) : r(r), c(c) {} // int DIR; }; int N; //迷宫数量 int W; //迷宫宽度 char map[maxn][maxn]; //地图 //方向 : 分别代表 上.右.下.左向量 ][] = { {-, }, {, }, {, }, {, -} }; bool vis[maxn][maxn]; //队…
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 may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonal…
在这一专辑(最小生成树)中的上一期讲到了prim算法,但是prim算法比较难懂,为了避免看不懂,就先用kruskal算法写题吧,下面将会将三道例题,加一道变形,以及一道大水题,水到不用高级数据结构,建树,画图,最短路径什么的,统统不需要.废话不多说,直接看题: 1.例题精讲 T1: 1348:[例4-9]城市公交网建设问题 时间限制: 1000 ms         内存限制: 65536 KB提交数: 2094     通过数: 650 [题目描述] 有一张城市地图,图中的顶点为城市,无向边代…