
算法
CC_且听风吟
行百里者半九十
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU 2087 剪花布条
kmp板题kmp的主要过程:获得next数组生成next数组的过程,其实就是可以看做模式串自己和自己进行匹配,找出所有子串的前后缀子串集合中的最长公共子串长度,然后在整体右移得到这句话好像有点绕。比如:abacda子串:{a, ab, aba, abac, abacd, abacda}生成next数组就是在下面这个事:子串a:前缀:{a} 后缀:{a} 最长公共:1子串ab:前缀:{a, ab} 后缀:{b, ba} 最长公共:0子串aba:前缀:{a, ab, aba} 后缀:{a,原创 2020-10-24 23:34:11 · 424 阅读 · 0 评论 -
打印沙漏
#include <iostream>using namespace std;int main(int argc, char const *argv[]){ int n; char ch; cin >> n >> ch; int m = 1; while((m+1)*(m+1)/2 - 1 <= n){ m += 2; } m -...原创 2019-07-10 00:19:59 · 179 阅读 · 0 评论 -
HDU 6043 KazaQ's Socks 找规律
题面:KazaQ's SocksTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3050Accepted Submission(s): 1601Problem DescriptionKazaQwears sock...原创 2019-07-17 00:33:09 · 179 阅读 · 0 评论 -
POJ 2718 暴力枚举
POJ2718Smallest DifferenceTime Limit:1000MS Memory Limit:65536K Total Submissions:19013 Accepted:5181 DescriptionGiven a number of distinct decimal digits, you can form o...原创 2019-07-11 13:16:15 · 306 阅读 · 0 评论 -
POJ 3187 求满足条件的全排列
POJ3187Backward Digit SumsTime Limit:1000MS Memory Limit:65536K Total Submissions:10529 Accepted:5964 DescriptionFJ and his cows enjoy playing a mental game. They write d...原创 2019-07-11 13:21:17 · 383 阅读 · 0 评论 -
HDU 4961 Boring Sum 预处理暴力
题面:Boring SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1646Accepted Submission(s): 756Problem DescriptionNumber theory is int...原创 2019-07-17 00:19:47 · 206 阅读 · 0 评论 -
HDU 4968 Improving the GPA 暴力枚举
题面:Improving the GPATime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 925Accepted Submission(s): 647Problem DescriptionXueba: Using t...原创 2019-07-17 00:25:18 · 279 阅读 · 0 评论 -
CF 670C - Cinema 题解
原题地址:http://codeforces.com/contest/670/problem/C题面:C. CinemaMoscow is hosting a major international conference, which is attended bynscientists from different countries. Each of the scientists...原创 2019-06-03 20:16:30 · 700 阅读 · 0 评论 -
并查集模板
带路径压缩:// 并查集模板int par[maxn];int _rank[maxn];// 初始化n个元素void init(int n){ for (int i = 0; i < n; ++i) { par[i] = i; _rank[i] = 0; }}// 查询树的根int find(int x){ if (par[x] == x) { ...原创 2019-07-11 14:29:12 · 147 阅读 · 0 评论 -
HDU 4970 差分转化前缀和
题面:Killing MonstersTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4237Accepted Submission(s): 1479Problem DescriptionKingdom Rush ...原创 2019-07-17 00:11:37 · 234 阅读 · 0 评论 -
快速幂
总结了四种方式:(1)计算(a*b)%c(模运算)typedef long long ll;ll mul(ll a,ll b,ll mod) { ll res = 0; while(b > 0){ if( (b&1) != 0) //二进制最低位是1 --> 加上 a的 2^i 倍, 快速幂是乘上a的2^i ) ...原创 2019-02-11 22:13:54 · 206 阅读 · 0 评论 -
gcd、lcm、ax+by=gcd(a , b)、ngcd、nlcm
(1)辗转相除法(欧几里得算法)gcd最大公因数 ,最大公约数int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}(2)最小公倍数lcmint gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int lcm(int a,int b){ return a/gcd(a,b)*b;...原创 2019-02-11 22:21:44 · 715 阅读 · 0 评论 -
HDU 4969 Just a Joke
题面: Just a Joke Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1121Accepted Submission(s): 505 Problem Description ...原创 2019-07-17 00:04:40 · 222 阅读 · 0 评论 -
HDU 6033 Add More Zero
题面:Add More ZeroTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3518Accepted Submission(s): 2007Problem DescriptionThere is a young...原创 2019-07-17 00:28:41 · 167 阅读 · 0 评论 -
POJ 3009 dfs回溯
POJ3009Curling 2.0Time Limit: 1000msMemory Limit: 65536KB64-bit integer IO format:%lld Java class name:MainDescriptionOn Planet MM-21, after their Olympic games this year, curlin...原创 2019-07-11 12:42:27 · 283 阅读 · 0 评论 -
POJ 3669 bfs+预处理
POJ3669Meteor ShowerTime Limit:1000MS Memory Limit:65536K Total Submissions:30551 Accepted:7861 DescriptionBessie hears that an extraordinary meteor shower is coming; rep...原创 2019-07-11 12:53:43 · 257 阅读 · 0 评论 -
POJ 3050 有深度限制的dfs
POJ3050HopscotchTime Limit:1000MS Memory Limit:65536K Total Submissions:6564 Accepted:4246 DescriptionThe cows play the child's game of hopscotch in a non-traditional way...原创 2019-07-11 13:28:43 · 403 阅读 · 0 评论 -
POJ 2010 区间最小和 - 优先队列
POJ2010 Moo University - Financial AidTime Limit: 1000msMemory Limit: 30000KB64-bit integer IO format:%lld Java class name:MainBessie noted that although humans have many universit...原创 2019-07-11 12:32:32 · 418 阅读 · 0 评论 -
POJ 3617 得到最小的字符串
POJ3617Best Cow LineTime Limit:1000MS Memory Limit:65536K Total Submissions:41592 Accepted:10630 DescriptionFJ is about to take hisN(1 ≤N≤ 2,000) cows to the annual"F...原创 2019-07-11 13:52:51 · 247 阅读 · 0 评论 -
POJ 3069 覆盖区间所需的最小数
POJ3069Saruman's ArmyTime Limit:1000MS Memory Limit:65536K Total Submissions:18338 Accepted:9013 DescriptionSaruman the White must lead his army along a straight path fro...原创 2019-07-11 14:00:08 · 160 阅读 · 0 评论 -
POJ 3253 切木板最小开销 贪心
POJ3253Fence RepairTime Limit:2000MS Memory Limit:65536K Total Submissions:71072 Accepted:23372 DescriptionFarmer John wants to repair a small length of the fence around ...原创 2019-07-11 14:19:41 · 497 阅读 · 0 评论 -
POJ 2431 加油站贪心 优先队列
POJ2431ExpeditionTime Limit:1000MS Memory Limit:65536K Total Submissions:28035 Accepted:7757 DescriptionA group of cows grabbed a truck and ventured on an expedition deep...原创 2019-07-11 14:25:36 · 210 阅读 · 0 评论 -
HDU 6034 Balala Power! 进制转换 贪心
题面:Balala Power!Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 8555Accepted Submission(s): 1991Problem DescriptionTalentedMr.Ta...原创 2019-07-17 00:40:21 · 231 阅读 · 0 评论 -
LCSubstring、LCSequence、LIS、LCIS、LICS
搞清楚一个事情:连续子序列==子串,这几个真的分不清楚子串:必须连续子序列:元素来自原串中,可以不连续1. // LCSubstring – 最长公共子串(两个串)最长公共子串长度就为max{c[i][j]}了int longestSubstring(string x, string y) { vector<vector<int> > f(x...原创 2019-01-19 15:33:55 · 359 阅读 · 0 评论 -
动态规划dp基础:求最大上升子序列和
题面:Super Jumping! Jumping! Jumping!Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I ...原创 2019-03-14 17:11:10 · 765 阅读 · 0 评论 -
POJ 1742 Coins 多重背包
POJ1742CoinsTime Limit:3000MS Memory Limit:30000K Total Submissions:47417 Accepted:15982 DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3...An ...原创 2019-07-18 22:18:40 · 235 阅读 · 0 评论