摘要:
[ 提交 ] [状态] 题目描述 The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the w 阅读全文
摘要:
# [USACO1.2]回文平方数 Palindromic Squares ## 题目描述 回文数是指从左向右念和从右向左念都一样的数。如 12321 就是一个典型的回文数。 给定一个用十进制表示的正整数 B,输出所有 [1,300] 中,它的平方用 B 进制表示时是回文数的数。 ## 输入格式 共 阅读全文
摘要:
//区间选点 //数轴上有 n 个闭区间 [a_i, b_i]。取尽量少的点,使得每个区间内都至少有一个点(不同区间内含的点可以是同一个) // //Input //第一行1个整数N(N<=100) //第2~N+1行,每行两个整数a,b(a,b<=100) // INPUT :2 //1 5 // 阅读全文
摘要:
dijkstra: ///朴素dijkstra算法 —— 模板题 AcWing 849. Dijkstra求最短路 I ///时间复杂是 O(n2+m)O(n2+m), nn 表示点数,mm 表示边数 #include<bits/stdc++.h> using namespace std; cons 阅读全文
摘要:
//单调队列 //hh为队头,tt为队尾 //最形象的例题:https://www.luogu.com.cn/problem/P1886#submit #include<bits/stdc++.h> using namespace std; const int N=1000010; int n,k; 阅读全文
摘要:
6-1 并查集 ///find函数可能有点难理解,自己尝试画下图随便理解好吧 ///M是合并,Q是询问是否在一个树中 #include<bits/stdc++.h> using namespace std; const int N=10010; int n,m; int q[N]; int find 阅读全文
摘要:
1 前缀和 /// 给定一组数,求任意区间的总和 #include<bits/stdc++.h> using namespace std; const int N=100010; int n,a[N],s[N],m; int main() { cin>>n>>m; for(int i=1;i<=n; 阅读全文
摘要:
//Satellite Photographs //农民约翰购买了卫星照片$W \times H$他的农场像素$(1 \le W \le 80, 1 \le H \le 1000)$并希望确定最大的“连续”(连接)牧场。 //当牧场中的任何一对像素可以通过遍历作为牧场一部分的相邻垂直或水平像素来连接 阅读全文
摘要:
///关于下标问题,当在计算时运用到i-1的时候,可以使用i从1开始,就没有越界的风险 ///如果没有,一般从0开始比价好; 1.要想明白动态规划路线 ->第一步写出动态集合,第二步开始动态计算; 1-1 0-1背包问题: #include<bits/stdc++.h> using namespac 阅读全文
摘要:
//DPS(深度搜索) //n-皇后问题 //方法一(与数字全排列相似) #include<bits/stdc++.h> using namespace std; const int N = 80; int n,res=0; char Q[N][N]; bool cow[N],dg[N],rdg[N 阅读全文
摘要:
这个题我做过类似的题目,没错,又是记忆化搜索,但也不完全是,还是用搜索就可以过,本质也是动态规划 基本上只要会简单的,就会做复杂的,只不过是步骤麻烦点 #include<bits/stdc++.h> using namespace std; int n,a[1000010]={1},res=1; v 阅读全文
摘要:
这个题我是不会用dp做,众所周知,能用记忆化搜索的题肯定能用dp,能用dp的不一定用记忆化搜索. 这个题正好用记忆化搜索可以过,欸嘿 #include<bits/stdc++.h> using namespace std; const int N=2020; int f[N][N],a[N][N], 阅读全文