摘要:
http://47.104.209.207/problem/old1059 直接用矩阵乘法的性质,注意0次方的时候是变成单位矩阵。 1 #include<cmath> 2 #include<iostream> 3 #include<queue> 4 #include<vector> 5 #inclu
阅读全文
posted @ 2021-02-24 12:09
greenofyu
阅读(66)
推荐(0)
摘要:
http://47.104.209.207/problem/old1058 先用筛法筛出所有质数,然后对每个数进行质因数分解。 1 #include<cmath> 2 #include<iostream> 3 #include<queue> 4 #include<vector> 5 #include
阅读全文
posted @ 2021-02-24 11:56
greenofyu
阅读(52)
推荐(0)
摘要:
http://47.104.209.207/problem/old1007 直接按位与。 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 #include<algorithm> 5 using namespace std; 6
阅读全文
posted @ 2021-02-23 22:59
greenofyu
阅读(24)
推荐(0)
摘要:
http://47.104.209.207/problem/old1072 需要用到高精度乘法(高精度数乘以int)。 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 #include<algorithm> 5 using na
阅读全文
posted @ 2021-02-23 22:51
greenofyu
阅读(51)
推荐(0)
摘要:
http://47.104.209.207/problem/old1071 直接用模板就好,反过来方便些。 1 #include<iostream> 2 #include<queue> 3 #include<vector> 4 #include<algorithm> 5 using namespac
阅读全文
posted @ 2021-02-23 22:33
greenofyu
阅读(50)
推荐(0)
摘要:
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
阅读(50)
推荐(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
阅读(57)
推荐(0)
摘要:
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
阅读(28)
推荐(0)
摘要:
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
阅读(34)
推荐(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
阅读(33)
推荐(0)