【ACM】
文章平均质量分 66
小do在努力
这个作者很懒,什么都没留下…
展开
-
【GCJ2016】 round 1A
A:The Last Word题意是给一个字符串,依次取出一个字母,然后将这些字母组成新串,组合的规则,只能放在当前串的串首或者串尾。求字典序最大的新串。 好简单,直接每次判断新取出的字母与当前组成的串的首字母比,比首字母大加到首部,否则加到尾部。#include <iostream>#include <cstring>#include <cmath>#include <algorithm>原创 2016-04-16 11:57:41 · 641 阅读 · 0 评论 -
Uva 10139 Factovisors
/** url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1080* stratege: 将除数m进行分解,分别求出质因子及其个数,然后对n进行判断,n中是否包含m的每个质因子下的个数,如果有,则可整除* Test Case: 16原创 2012-08-29 16:00:42 · 818 阅读 · 0 评论 -
HDU 2612 find the way 双向BFS
/*--------------------------------------------------------- stratege : BFS,对Y和M的位置,都进行广搜, 并且Y可以走到M的位置,M可以走 到Y的位置 Author :johnsondu Time : 2012.2.18 18:25-17:原创 2012-02-19 19:44:53 · 1091 阅读 · 0 评论 -
HDU 1312 Red and Black
看了好多天的DFS,基本上的程序都是要借助解题报告才可以实现但是这一题,确实依照自己的思路,完全靠自己写出来的,或许比较简单吧,所以特此发表下文章,犒劳一下自己,再接再厉http://acm.hdu.edu.cn/showproblem.php?pid=1312Red原创 2011-08-15 14:51:48 · 2410 阅读 · 0 评论 -
UVA 972 Horizon Line 离散化
/** problem: UVA 972 Horizon Line* url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=913* strtege: 离散化* Author: johnsondu* time: 2013-4-25*/#i原创 2013-04-25 22:09:11 · 923 阅读 · 0 评论 -
POJ 2479 Maximum sum
/*** Author: johnsondu* Stratege: DP* ItemName: StepByStep to learn DP well* ProblemAndUrl: Maximum sum http://poj.org/problem?id=2479**/#include #include #include #include #includ原创 2013-03-29 21:54:22 · 1306 阅读 · 0 评论 -
Sicily 1721 Gray code[Special judge]
/** url : http://soj.me/show_problem.php?pid=1721&cid=* Problem Name: Gray Code* Statege: Brute Force* Characteristics: the neighbourhood's code should have exzactly one different* S原创 2012-08-28 16:07:18 · 829 阅读 · 0 评论 -
HDU 2112 HDU Today Dijkstra
/*---------------------------------------------------- stratege : Dijkstra ; KeyPoint : Transform char to matrix ; status : 2012-05-17 00:06:30 Accepted 1003 531 MS 328 KB原创 2012-05-17 00:13:08 · 974 阅读 · 0 评论 -
NYOJ 2 括号配对问题 数据结构栈的应用
#include #include #include #include #include using namespace std ;const int MAXN = 10005 ;char str[MAXN] ;bool flag ;void judge (){ int i ; int len ; char ch ; stack Q ;原创 2012-04-04 13:07:41 · 823 阅读 · 0 评论 -
HDU 3853 LOOPS 概率dp入门 (1)
/*** Author : johnsondu* time: 2012-10-13-9:30 around* url: http://acm.hdu.edu.cn/showproblem.php?pid=3853* stratege: 概率dp**/#include #include #include #include #include using namespace s原创 2012-10-13 09:49:13 · 912 阅读 · 0 评论 -
HDU 1241 Can you find it?
/*-------------------------------------------- stratege : 二分查找 basic step : int find (int min, int max, int x) // min是已排列的数组的下限,max为上限,x为所要查找的值 { int原创 2012-02-08 20:24:50 · 767 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone
关于DFS如何学好,先援引大牛的几点建议:(1)先理解搜索的原理,区别好bfs和dfs的优先搜索方向以及应用,例如bfs一般用来求最优解如最短路径.(2)掌握好所用的数据结构,特别是队列.(3)牢记dfs和bfs的常用模式,它是基本固定的,考试时信手拈来!(4)注原创 2011-08-10 16:34:57 · 1595 阅读 · 3 评论 -
HDU 1211 RSA 逆元 快速模取幂
/** * url: http://acm.hdu.edu.cn/showproblem.php?pid=1211 RSA * Author: Johnsondu * Time: 2012-7-28 18:00 around * Stratege: 逆元(扩展欧几里德) , 快速模取幂 * Status: 6364213 2012-07-28 18:12:54 Accepte原创 2012-07-28 18:16:27 · 1619 阅读 · 1 评论 -
Uva 10168 Summation of Four Primes 素数
/** Status: 10540903 10168 Summation of Four Primes Accepted C++ 0.864 2012-08-30 02:49:48* url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1原创 2012-08-30 10:52:12 · 817 阅读 · 0 评论 -
POJ 3641 HDU 1905 Pseudoprime numbers 素数 模取幂
/*--------------------------------------------------- status : a312745658 3641 Accepted 328K 16MS C++ 1732B 2012-05-18 21:36:37 stratege : 快速模取幂,素数筛选, 判断一个大数是否为素数 URL: http:原创 2012-05-18 21:40:27 · 1695 阅读 · 2 评论 -
HDU 1019 Least Common Multiple
/*-------------------------------------------------------------------- stratege:素数筛选 + 整数拆分 一个整数x = p1^a1 + p2 ^ a2 + ... + pn ^ an 其中pi为素数。本题关键是找到存在pi^ai 中 ai的原创 2012-03-22 12:41:56 · 648 阅读 · 0 评论 -
HDU 1020 Train Problem I 栈和队列的应用
/*---------------------------------------- stratege :stack && queue && simulation Theam : 给你一系列数,一次进栈,问出栈的 顺序是否符合 Author: Johnsondu Time: 2012-04-04 type: data structure原创 2012-04-04 18:05:14 · 945 阅读 · 0 评论 -
【树状数组】POJ 2309 BST
树状数组第一步,了解如何获取一个整数的最后一位是1的数原创 2015-08-19 16:41:43 · 577 阅读 · 0 评论 -
杭电OJ 题目分类
<br /><br />1001 入门1002 简单的大数<br />1003 DP经典问题,最大连续子段和<br />1004 简单题<br />1005 找规律(循环点)<br />1006 感觉有点BT的题,我到现在还没过<br />1007 经典问题,最近点对问题,用分治<br />1008 简单题<br />1009 贪心<br />1010 搜索题,剪枝很关键<br />1011 <br />1012 简单题<br />1013 简单题(有个小陷阱)<br />1014 简单题<br />101转载 2011-04-18 21:29:00 · 7651 阅读 · 2 评论 -
UVA 343 What Base Is This?
/*---------------------------------------------------- Author : Johnsondu Stratege : 水题, 注意要用long long, 没有1进制 10000845 343 What Base Is This? Accepted C++ 0.016 2012-04-17 11:30:42---原创 2012-04-17 19:58:32 · 943 阅读 · 0 评论 -
HOJ 1020
Encoding<br />Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 9952 Accepted Submission(s): 4110<br /><br />Problem DescriptionGiven a string containing only 'A' - 'Z', we could encode it usi原创 2011-04-19 12:03:00 · 955 阅读 · 0 评论 -
杭电动态规划
<br />本文来自CSDN博客,转载:http://blog.csdn.net/qishibo1990/archive/2010/04/25/5527736.aspx<br /> <br />Robberies http://acm.hdu.edu.cn/showproblem.php?pid=2955<br />背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱 最脑残的是把总的概率以为是抢N家银行的概率之和… 把状态转移方程写成了f[j]=max{f[j],f[转载 2011-04-23 16:26:00 · 1490 阅读 · 0 评论 -
筛选法 求素数 一个数的所有因素和
/*--------------------------------------- 素数筛选法---------------------------------------*/#includeint x[20000000];int main(){ int temp, n, i; for( i = 0; i < 20000000; i ++ )原创 2012-02-15 18:52:34 · 897 阅读 · 0 评论 -
PKU Prime Gap 3518 简单素数
/* stratege : 素数 URL:http://poj.org/problem?id=3518 Problem: 3518 User: a312745658 Memory: 5684K Time: 94MS Language: C++ Result: Accepted*/#include #include #include原创 2012-03-13 22:45:21 · 794 阅读 · 0 评论 -
HDU 2544 最短路 dijkstra floyd
纯属复习数据结构/* stratege : floyd Status : 2012-05-14 23:34:01 Accepted 1002 31 MS 268 KB Visual C++ johnsondu*/#include #include #include #include #include #include using原创 2012-05-14 23:34:56 · 736 阅读 · 0 评论 -
HDU 4004 The Frog's Games
/*-------------------------------------------------------------- stratege : 二分查找 + 贪心 time :2012.2.8 20:43 -- 21: 23 URL : http://acm.hdu.edu.cn/showproblem.php?pid=4004********原创 2012-02-08 21:25:17 · 1047 阅读 · 0 评论 -
HDU 1588 Gauss Fibonacci 矩阵
/** *stratege: 构造矩阵 A = |1 1| * |1 0| * 矩阵快速幂,二分求和 *status: johnsondu B Accepted 252 KB 15 ms C++ 3113 B **/#include #include #include #include #inc原创 2012-08-14 10:56:28 · 719 阅读 · 0 评论 -
HDU 2579 Dating with girls(2) BFS
/*--------------------------------------------- Time : 14:45-15:25 2012.2.13 Stratege : BFS (KeyPoint:定义一个三维数组,num[x][y][z] ; x, y用于存放当前所在的迷宫坐标,z用于存放所走过的 时间和题目原创 2012-02-13 15:27:27 · 950 阅读 · 0 评论 -
POJ 2251 Dungeon Master BFS
这题其实是一题简单的BFS,代码注释如下程序所示:/*----------------------------------------------------- Time : 19:00 - 19:53 2012.2.12 stratege : BFS Author : Johnsondu--------------------------------------------原创 2012-02-12 19:57:23 · 844 阅读 · 0 评论 -
HDU 1879 继续畅通工程
还是一题典型的prim算法。 普里姆算法(Prim's algorithm)是图论中的一种算法,可在加权连通图里搜索最小生成树。意即由此算法搜索到的边子集所构成的树中,不但包括了连通图里的所有顶点(英语:Vertex (graph theory)),且其所有边的权值之和亦原创 2011-08-20 20:59:22 · 674 阅读 · 0 评论 -
POJ 1016 Numbers That Count 模拟
#include #include #include #include #include using namespace std ;const int MAXN = 100 ;char str[16][MAXN] ;char tmp[MAXN] ;int mark[MAXN] ;int ans1, ans2, len ;bool flags, flagi ;void j原创 2012-05-25 00:13:52 · 775 阅读 · 0 评论 -
杭电 1562
杭电 1562 暴力搜索其实这题就是一题傻瓜题,原本我以为暴力搜索是一个很高深的东西,没想到就是没有优化的进行一个一个的搜索学过for循环语句的同学,一定也知道这题该怎么做吧#includeusing namespace std;int main(){ int tcase, a, b, c, i, p; cin >> tcase; while ( tcase -- ) { p = 0; cin >> a >> b >>c; for ( i =原创 2011-04-18 21:51:00 · 981 阅读 · 0 评论 -
NYOJ38 布线问题 prim算法 kruscal算法
/* problem : NYOJ38 布线问题 stratege: kruscal algorithm URL :http://acm.nyist.net/JudgeOnline/problem.php?pid=38 status :166386 1006100213 布线问题 Accepted 76 4216 C/C++ 05-13 21:57:42*/原创 2012-05-13 21:25:21 · 1391 阅读 · 0 评论 -
PKU 1631 Bridging signals 二分查找
#include #include #include #include using namespace std ;int res[40005] ; //保存非线性递增队列的结果int n, resLen ;void Insert (int low, int high, int val){ int mid ; while (low <= high) {原创 2012-04-04 12:18:57 · 675 阅读 · 0 评论 -
HDU 2473 Junk-Mail Filter
/*转载自 ______________白白の屋 */#include #include #include#includeusing namespace std;int set[1350005];int a[125000];int N,M原创 2011-08-22 15:25:40 · 847 阅读 · 0 评论 -
POJ 3070 Fibonacci 矩阵乘法 整数分解
#include #include #include #include #include using namespace std ;int a[100][2][2] ;int n, base[30], len;void init () // 此处主要用于计算当n=1,2,4,8,16...f[n]的值,此时对应的k为0,1,2,3,...{ a[0][0][0] =原创 2012-05-04 22:49:26 · 1351 阅读 · 0 评论 -
POJ 3126 Prime Path BFS 广度优先搜索 素数
/*--------------------------------------- stratege : 素数判断(先打表), BFS Author : Johnsondu Problem: 3126 User: a312745658 Memory: 276K Time: 47MS Language: C++ Result: Accepted-原创 2012-03-14 22:02:30 · 822 阅读 · 0 评论 -
Uva 10090 Marbles 扩展欧几里得 费用最小
/** url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1031* stratege: 求n1*x+n2*y=n, x*c1+y*c2的值最小, 扩展欧几里得,分2种情况考虑,x的最小正整数解, y的最小正整数解* status:原创 2012-08-30 16:10:19 · 1181 阅读 · 0 评论 -
uva 10830 A New Function
/** Author: johnsondu* time: 2013-4-25* problem: uva 10830 - A New Function* url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1771* so原创 2013-04-26 17:03:12 · 1530 阅读 · 0 评论 -
HDU 2845 Beans
/** Author: johnsondu* Time : 2013-5-1* problems: HDU 2845 Beans* url: http://acm.hdu.edu.cn/showproblem.php?pid=2845* stratege: dynamic programming* state transition equation: dp[i原创 2013-05-01 16:24:29 · 920 阅读 · 0 评论