上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 22 下一页

2021年2月6日

摘要: https://www.acwing.com/problem/content/435/ 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 string s; 5 cin>>s; 6 int res=0; 7 for(int 阅读全文
posted @ 2021-02-06 20:05 greenofyu 阅读(45) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/91/ 考察快速幂的知识; 1 #include<iostream> 2 using namespace std; 3 typedef long long LL; 4 LL ksm(LL a,LL b,LL p){ 5 L 阅读全文
posted @ 2021-02-06 19:52 greenofyu 阅读(41) 评论(0) 推荐(0)

2021年2月3日

摘要: 1、最长公共子序列问题 https://www.acwing.com/problem/content/899/ 写代码时,因为 f ( i-1 , j ) 包含了 f ( i-1 , j-1 ) ,所以一般是不将其写出来的。 初始值的话,根据定义考虑,将 f [ 0 , 0~m ],f [ 0~n 阅读全文
posted @ 2021-02-03 21:26 greenofyu 阅读(61) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1103/ 搜索题,数据范围为1<=n,m<=200。 所以dfs是必然超时的,时间复杂度为(200*200)! 1 void dfs(PII now,PII e,int step){ 2 if(now==e){ 3 re 阅读全文
posted @ 2021-02-03 15:20 greenofyu 阅读(119) 评论(0) 推荐(0)

2021年2月2日

摘要: https://www.acwing.com/problem/content/1404/ 考察flood fill 和 图的hash。 这题有两问:1、找出图中的全部连通块 2、根据形状给给将相似的连通块换上同一个字符 对于第一问,可以直接应用flood fill算法。 对于第二问,我们可以通过ha 阅读全文
posted @ 2021-02-02 16:10 greenofyu 阅读(109) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/705/ 考虑每个独立方块的左上角和右下角。 单独检查每一个独立方块。 1 #include<iostream> 2 #include<unordered_map> 3 using namespace std; 4 con 阅读全文
posted @ 2021-02-02 11:45 greenofyu 阅读(150) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/428/ 给定总钱数n,和m个物品,每个物品有价格和重要度两个属性。 问在总价格不超过n的情况下,选中物品的价格*重要度的和最大是多少。 可以抽象为01背包模型,总钱数为背包容量,价格为物品体积,价格*重要度为物品价值。 阅读全文
posted @ 2021-02-02 11:21 greenofyu 阅读(50) 评论(0) 推荐(0)

2021年1月31日

摘要: A:模拟题,枚举每一个数,然后求出他应该放在哪一个盒子里面,时间复杂度为n*lgn 1 class Solution { 2 public: 3 int countBalls(int l, int r) { 4 vector<int> cnt(50,0); 5 int res=0; 6 for(in 阅读全文
posted @ 2021-01-31 22:33 greenofyu 阅读(68) 评论(0) 推荐(0)

2021年1月30日

摘要: A:题意是给定n,k,求一个包含n个正整数的序列,满足序列和能够整除k,输出该序列最小的最大值。 如果n<=k,res等于k/n+(k%n != 0) 如果n>k,那么需要将k乘上一个数z,使得k>=n。而这个z=n/k+(n%k != 0),之后再进行上述操作。 1 #include<iostre 阅读全文
posted @ 2021-01-30 17:25 greenofyu 阅读(51) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/128/ 考察二位前缀和知识。 应用容斥定理写出计算公式,O(1)时间计算子矩形的和。 可以直接枚举每个子矩形的左上和右下角。时间O(n^4),1<=n<=100 故时间合格。 1 #include<iostream> 2 阅读全文
posted @ 2021-01-30 14:18 greenofyu 阅读(58) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 22 下一页