- 博客(5)
- 收藏
- 关注
原创 ZOJ
ZOJ——2833 并查集的寻根和合并操作 #include <iostream> using namespace std; int friends[100005]; //寻找根节点 int find(int x) { while(friends[x]>0) x=friends[x]; return x; } //合并两节点 void Union(int x, int y) { int r1=find(x); int r2=find(y)
2021-04-14 21:10:27 103
原创 2021-03-12
【ZOJ】1383—Binery Numbers 题目原题: Given a positive integer n, print out the positions of all 1’s in its binary representation. The position of the least significant bit is 0. Example The positions of 1’s in the binary representation of 13 are 0, 2, 3. Task Wr
2021-03-12 19:13:30 132
原创 【每日一练】UVa10340-All in All 字符串
题目大意:输入两个字符串s和t,判断是否能从t中删除0个或多个字符(其他字符顺序不变),得到字符串s。例如:abcde可以得到bce,但无法得到dc。 原题链接 写的一个伪代码: cin>>s>>t; for(j=0; j<t.size(); j++) if(s[i] = t[j]) i++; if(i==s.size()) cout<<“Yes”; else cout<<“No”; AC代码: #include <iostream> #
2020-05-11 09:16:55 167
原创 【每日一练】UVa1588 换抵挡装置-Kickdown
点击跳转题目链接 写题解是为了记录自己的成长和思考该题的方式,同时锻炼自己的能力,注释我会详细写出自己哪里纠结了很久的地方,以及相关的一些知识点,有错误还请各位大佬指出。 本题关键:高度限制3h,要对应缝隙,用相加<3解决,有顺序限制,需要来回讨论。 方法:找出大小串,以大的在上,小的从左蹭到右,之后顺序同时反转再蹭一遍。 这是我做题时画的一个简单流程图: 以下是AC代码: 下面展示一些 内联代码片。 #include <iostream> #include <st
2020-05-09 00:22:25 218
原创 【每日一练】UVa11809 浮点数
第一次写题解,WA了无数次还是没有发现问题,先放着吧,以后再回来研究(orz) 解题思路:暴力解法,因为直接用double很容易爆内存,所以用对数。 下面是 解题代码。 #include <iostream> #include <cstring> #include <stdio.h> #include <cmath> using namespace ...
2020-05-07 17:50:19 194 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人