摘要: 题目 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6567 Problem Description Avin has two trees which are not connected. He asks you to add an edge betwee 阅读全文
posted @ 2021-05-21 17:35 _comet 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 题目 链接:https://ac.nowcoder.com/acm/contest/15644/B来源:牛客网 A gene tree is a tree showing the evolution of various genes or biological species. A gene tre 阅读全文
posted @ 2021-05-08 22:41 _comet 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 题目链接:https://www.luogu.com.cn/problem/U155612 题目有点问题,不能主动检测代码是否合法,就算你用while for,同样能过。但我这次写的的确是只使用if和printf的解法。 由于代码提交有文本上限,所以直接写肯定提交不了。所以我采用的方法的宏定义(宏定 阅读全文
posted @ 2021-03-22 20:35 _comet 阅读(80) 评论(0) 推荐(0) 编辑
摘要: template <class T> class heap { vector<T>data; public: heap() {} heap(T *a,int len) { for (int i = 0; i < len; i++) data.push(a[i]); } T top() { retur 阅读全文
posted @ 2020-12-16 15:50 _comet 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 题目 Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length 阅读全文
posted @ 2020-11-25 15:18 _comet 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题目 输入n,问从坐标(0,0)点能看到多少点,点的坐标范围是0<=(x,y)<=n只有一个点没有被另一个点挡住才能看到。如上图,n=5的时候,能看到21个点 Input 第一行输入t,表示样例个数。1<=t<=1000 接下来t行,每行输入一个正整数n 。 1<=n<=1000 Output 输出 阅读全文
posted @ 2020-10-25 15:12 _comet 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 说起斐波那契数列大家应该都很熟悉,一个简单的递推公式 大家应该很容易想出形如这样的代码。 int fib(int x) { if (x == 1 || x == 2)return 1; return fib(x - 2) + fib(x - 1); } 一个经典的递归方法。 但这个代码的时间复杂度很 阅读全文
posted @ 2020-10-09 22:01 _comet 阅读(665) 评论(0) 推荐(2) 编辑
摘要: 题目 Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. In each turn, the cows would stan 阅读全文
posted @ 2020-10-05 18:11 _comet 阅读(287) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stack>template <class T> class node { public: T data; int height; node<T>* left; node<T>* right; node() { left = nullptr; r 阅读全文
posted @ 2020-09-26 19:48 _comet 阅读(287) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; template <class T> class Node{ public: Node<T>* next; Node<T>* prev; T data; Node() { next = nullptr; prev = n 阅读全文
posted @ 2020-09-20 10:30 _comet 阅读(660) 评论(0) 推荐(0) 编辑