随笔分类 - 解题报告
-
蓝桥杯--2N皇后问题
摘要: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 阅读全文
-
AcWing每日一题--拼写正确
摘要:https://www.acwing.com/problem/content/1479/ 水题。 得到sum后可每一次提取个位数字,或直接将其to_string。 解法一: 1 #include<iostream> 2 #include<algorithm> 3 using namespace st 阅读全文
-
AcWing每日一题--数字反转
摘要: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( 阅读全文
-
AcWing每日一题--质因数分解
摘要:https://www.acwing.com/problem/content/451/ 水题。 确定p有且仅有两个质因子。 故可直接枚举较小的那个质因子。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int p; 5 阅读全文
-
AcWing每日一题--数字统计
摘要: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 阅读全文
-
AcWing每日一题(提高组)--聪明的质监员
摘要: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]; 阅读全文
-
AcWing每日一题(提高组)--耍杂技的牛
摘要:https://www.acwing.com/activity/content/code/content/846810/ n个牛进行叠罗汉,每头牛有一个重量w和强壮程度s,风险等级定义为头上的牛的质量减去我的强壮程度,问如何叠最大的风险等级最小。 1 #include<algorithm> 2 #i 阅读全文
-
AcWing每日一题--比例简化
摘要:https://www.acwing.com/problem/content/460/ 发现L的范围只有100,直接枚举分子分母。 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int gcd(int a,int b) 阅读全文
-
AcWing每日一题(提高组)--糖果传递
摘要:https://www.acwing.com/problem/content/submission/124/ n个同学围成一个圈,每个同学手上有ai个糖果,每传递一个糖果代价为1,问最少代价为多少使得糖果均分。 将解得的x1,x2....xn带入目标式子中。 所以只需要构造一种糖果传递方案,使得每次 阅读全文
-
AcWing每日一题(提高组)--数度简单版
摘要:https://www.acwing.com/problem/content/1615/ 写出一个正确的dfs就可以了。 1 #include<iostream> 2 using namespace std; 3 char s[9][9]; 4 bool row[9][10],col[9][10], 阅读全文
-
AcWing每日一题(提高组)--K倍区间
摘要:https://www.acwing.com/problem/content/1232/ 求出一个数组中是k的倍数的连续子序列有多少个。 因为数组元素大于0,所以保证前缀和数组是一个单调上升数组。 将前缀和数组分为k类,模k为0,模k为1... 对于每一个前缀和只需要找和他同类的有多少个就可以了。 阅读全文
-
AcWing每日一题(提高组)--牛异或
摘要:https://www.acwing.com/problem/content/1416/ 给定一串序列,要找到异或值最大的子串。 在保证右端点最小的前提下保证长度最小。 对于异或的性质 a^b^a = b,可以将前缀和应用于该题。 这样的话只需要枚举左端点和右端点,但是时间复杂度为n^2,计算之后达 阅读全文
-
AcWing每日一题--明明的随机数
摘要:https://www.acwing.com/problem/content/427/ 水题。 unique函数是将相邻的相同的元素去除掉,返回的是最后一个元素的下一个迭代器,时间复杂度为n。 1 #include<algorithm> 2 #include<iostream> 3 using na 阅读全文
-
AcWing每日一题(提高组)--加分二叉树
摘要:https://www.acwing.com/problem/content/481/ 给定从1~n编号的n个节点和他们各自的权值,构造出一颗中序遍历为1~n的得分最大的二叉树,输出其得分和前序遍历。 得分规则具体如下:如果根节点既有左子树又有右子树,那么得分=左子树*右子树+根节点权值 如果左子树 阅读全文
-
AcWing每日一题--不高兴的津津
摘要:https://www.acwing.com/problem/content/419/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int max_time=0,max_day=0; 5 for(int i= 阅读全文
-
AcWing每日一题--陶陶摘苹果
摘要:https://www.acwing.com/problem/content/423/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int a[10]; 5 for(int i=0;i<10;i++){ 6 阅读全文
-
AcWing每日一题--数列
摘要:https://www.acwing.com/problem/content/430/ 考察快速幂相关知识。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int k,n; 5 cin>>k>>n; 6 int res 阅读全文
-
AcWing每日一题--ISBN号码
摘要: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 阅读全文
-
AcWing每日一题--a^b
摘要: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 阅读全文
-
AcWing每日一题--献给阿尔吉侬的花束
摘要: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 阅读全文