随笔分类 - 解题报告
摘要:题意: 树的前,中序遍历求后序遍历。基础题。code#include #include using namespace std;string sq, sh;int len;void make (int l, int r, int t, int w) { if (l > r || t > w) r...
阅读全文
摘要:分析: 2*n个小朋友,每个最多有n-1个"敌人",显然是存在哈密顿回路的. 预处理边,然后找哈密顿回路.code#include #include #include #include #include using namespace std;#define pb push_back#def...
阅读全文
摘要:分析: 基础的欧拉路算法,变化在于要求每条边正向和反向各走一遍。 链式前向星构图,只要标记走过的单向边,边找边输出即可。code#include #include using namespace std;struct node { int v, ne;} edge[100009];int h...
阅读全文
摘要:简单的搜索,在n>10时,要打表code:#include#include#includeusing namespace std;const int maxn = 20, N = 14;int n, p[maxn], ans = 0;void dfs (int emp){ int i, j, p0[...
阅读全文
摘要:时间限制:0.25s空间限制:6M题意: 给出n(n#include #include #include #include #include using namespace std;struct node { int key, val, ID;} p;struct answer { int fa...
阅读全文
摘要:题意: 一个取火柴游戏,可以取的数在一个集合S内,S必包含1,且不超过9个数,每个数都不大于9.最后取完者失败。 求n(n#include int a[12],n,m;int SG[1060],hash[1060];void GetSG(int Array[], int N){ int...
阅读全文
摘要:时间限制:0.25s空间限制:4M题意 你的任务是找到最小自然数 N, 使N!在十进制下包含 Q个零. 众所周知 N! = 1*2*...*N. 例如, 5! = 120, 120 结尾包含1个零.Input 一个数 Q (0using namespace std;int check ...
阅读全文
摘要:不断向下取直到,忽略的数累计到一个百分比,给当前百分比加1。 这道题要避免处理浮点数,用余数来处理,不然会wa 9 #include #include using namespace std;int g[10001];int x, n, sum, le;int main() { cin >>...
阅读全文
摘要:非常烦人的题,思路比较简单,十分容易出错,细节非常重要。从四个不同的行走方向讨论经过的每一个格子。code:#include #include #include using namespace std;#define lb long double#define fi first#define se ...
阅读全文
摘要:所有代码都不超过40行。。。A:http://www.cppblog.com/willing/archive/2010/05/04/114304.htmlB:http://www.cnblogs.com/keam37/p/3849933.htmlC:http://www.cnblogs.com/ke...
阅读全文
摘要:Solution: 这其实是道很简单的题。 只要从一端开始,以‘+’或‘-’,任意一种开始找,找到与目标串最近的相同字符的距离就是需要交换的次数。 +++——— 对齐第一个‘-’ —+++—— ---...
阅读全文
摘要:没什么好说的离散化求逆序对,树状数组即可code#include #include #define INF 66666using namespace std;int A[INF], g[INF], pos[INF], n;long long ans;void update (int x, int k...
阅读全文
摘要:时间限制:0.25s空间限制:12M题意 给定一个合法的仅由'(',')'组成的括号序列,求它的下一个合法排列.假定'('f[j]; 将最后的‘)’和‘(’ 交换位置,再把后面所以的括号反转。即可得到我们需要的解。code:#include #include #include usi...
阅读全文
摘要:时间限制:0.5s空间限制:4M题意: 令X0=A, Xi=(a*Xi-1^2,b*Xi-1+c)%m; 求Xk,(0#include #include #include using namespace std;const int INF = 111111;vector ans;...
阅读全文
摘要:时间限制:0.25s空间限制:4M;题意: 给出一颗n(n#include #include #include using namespace std;#define mp make_pair#define fi first#define se second#define sz(x) ((int...
阅读全文
摘要:时间限制:0.25s空间限制:4M题目 在离著名的国家Berland不远的地方,有一个水下工作站。这个工作站有N层。已知:是第层装有Wi的水,最多可以容纳Li的水,恐怖分子炸毁第i的代价是Pi。第i层一旦被炸毁,该层所有的水都将倾泻到第i+1层。如果某一层的水量超过了它的容量(即Li),那么该...
阅读全文
摘要:时间限制:0.25s空间限制:4M题意: 在一个N*N(N = T-1的时候还没有交集,表明黑王和白王已经相遇,总步数为T-1。总复杂度O(N)。代码: #include#includeusing namespace std;int n, d, st, ans;struct Point{ int...
阅读全文
posted @ 2014-07-13 19:07
keambar
摘要:时间限制:0.25s空间限制:4M题意: 一个人在一个周长为L的圆上跑,每个时间段(Ti)的速度(Vi)不一样,问最后他离起点的圆弧距离,周长是个有四位小数的浮点数,其它全是整数。Solution : 在遇到浮点数的时候,能避免处理就尽量避免处理。 这里只要将浮点数乘上1000...
阅读全文
摘要:时间:0.25s空间:4m题意: 其实就是求无环第K短路。 输入: 给出n,m,k,分别代表,n个点,m条边,第k长路。 接下来m行,三个整数x,y,z,分别代表x,y之间有条费用为x的双向路。保证没有重边。输出: 第一行两个数a,b,第k小费用a,和经过的点的...
阅读全文
摘要:题目: 两支地区ACM比赛的队伍决定为了国际决赛而在一起集训. 他们约定在某天的 X 时到 Y 时的某一时刻相会. 但由于他们很少按时到 (有的队伍比赛那天都会迟到), 他们没有设定一个确切的相遇时间. 然而, 它们约定先到的队伍要等待 Z 分钟(经过计算,他们认为如果过了这么久还没等...
阅读全文

浙公网安备 33010602011771号