上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页

2021年2月23日

摘要: http://47.104.209.207/problem/old1070 问Huffman树的费用,直接用堆解决。 1 #include<iostream> 2 #include<queue> 3 4 using namespace std; 5 6 int main(){ 7 int n; 8 阅读全文
posted @ 2021-02-23 22:25 greenofyu 阅读(40) 评论(0) 推荐(0) 编辑
摘要: http://47.104.209.207/problem/old1069 先dfs黑皇后然后dfs白皇后,因为麻烦所以直接暴力check当前位置是否合法。 1 #include<iostream> 2 const int N=20; 3 4 using namespace std; 5 int s 阅读全文
posted @ 2021-02-23 22:20 greenofyu 阅读(45) 评论(0) 推荐(0) 编辑

2021年2月19日

摘要: A:给定一个序列,一个操作是向其中任何一个位置插入一个数,问至少需要多少次操作才能保证两两之间的max(a[i],a[i+1])/min(a[i],a[i+1])<=2。 假设在i和i+1之间插入一个数,这个操作并不会影响到其他,所以我们可以线性的考虑整个序列。 那么我们现在只需要考虑如果a和b,m 阅读全文
posted @ 2021-02-19 17:00 greenofyu 阅读(18) 评论(0) 推荐(0) 编辑

2021年2月16日

摘要: A:问能否将一个数组通过轮换的方式得到一个单调不减的数组。 因为范围只有100,直接将数组拷贝并排序,然后对原数组轮换n次,每次进行一下判断。 1 class Solution { 2 public: 3 bool check(vector<int>&a,vector<int>& b){ 4 int 阅读全文
posted @ 2021-02-16 21:19 greenofyu 阅读(26) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/1479/ 水题。 得到sum后可每一次提取个位数字,或直接将其to_string。 解法一: 1 #include<iostream> 2 #include<algorithm> 3 using namespace st 阅读全文
posted @ 2021-02-16 19:38 greenofyu 阅读(18) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/447/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int n; 5 cin>>n; 6 int res=0; 7 while( 阅读全文
posted @ 2021-02-16 19:35 greenofyu 阅读(13) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/451/ 水题。 确定p有且仅有两个质因子。 故可直接枚举较小的那个质因子。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int p; 5 阅读全文
posted @ 2021-02-16 19:34 greenofyu 阅读(12) 评论(0) 推荐(0) 编辑
摘要: https://www.acwing.com/problem/content/443/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int l,r; 5 cin>>l>>r; 6 int cnt=0; 7 f 阅读全文
posted @ 2021-02-16 19:33 greenofyu 阅读(11) 评论(0) 推荐(0) 编辑

2021年2月11日

摘要: https://www.acwing.com/problem/content/501/ 1 #include<iostream> 2 using namespace std; 3 const int N=200010; 4 typedef long long LL; 5 int v[N],w[N]; 阅读全文
posted @ 2021-02-11 16:40 greenofyu 阅读(59) 评论(0) 推荐(0) 编辑

2021年2月10日

摘要: https://www.acwing.com/activity/content/code/content/846810/ n个牛进行叠罗汉,每头牛有一个重量w和强壮程度s,风险等级定义为头上的牛的质量减去我的强壮程度,问如何叠最大的风险等级最小。 1 #include<algorithm> 2 #i 阅读全文
posted @ 2021-02-10 22:58 greenofyu 阅读(52) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页