上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: 铺地毯 覆盖地面某个点的最上面的那张地毯的编号 从后往前枚举,前提是这个点在地毯上面 #include<bits/stdc++.h> #define maxn 100005 using namespace std; struct Node{ int x,y,up,right; }a[maxn]; i 阅读全文
posted @ 2020-06-22 08:53 chstor 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 数学考试 区间求和问题可以想到一个常用算法:前缀和。区间的和可以用方便地求出。 维护第一个长度为k的最大值,枚举第二个长度为k的起点,答案就是max(ans,当前长度为k的序列和+第一个长度为k的序列和) #include<bits/stdc++.h> using namespace std; #d 阅读全文
posted @ 2020-06-22 08:50 chstor 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 一、枚举 一一列举 不重复、不遗漏 优化枚举的基本思路:——减少枚举次数 1、选择合适的枚举对象 2、选择合适的枚举方向——方便排除非法和不是最优的情况 3、选择合适的数据维护方法——转化问题 eg:数列求和问题 给你一个数列(1≤n≤100000),有q(1≤q≤100000)次询问,每次询问数列 阅读全文
posted @ 2020-06-21 18:33 chstor 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 奇♂妙拆分 简单的质因子拆分题,计数注意是从1开始. #include<bits/stdc++.h> using namespace std; void chai(int n){ int cnt=1; for(int i=1;i<sqrt(n);i++){ if(n%i==0){ n/=i; cnt 阅读全文
posted @ 2020-06-19 21:28 chstor 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 糖糖别胡说,我真的不是签到题目 先假设所有人都不会被消灭,求出第n秒的所有人的战力 从后往前遍历,分别记录两个队的战力最大值,如果第i个人的战力小于后面另一个队的最大战力值,则一定会被消灭 #include<bits/stdc++.h> using namespace std; #define ll 阅读全文
posted @ 2020-06-19 21:14 chstor 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 1017 A除以B (20分) orz柳诺小姐姐的代码 //模拟手动除法的过程,每次用第一位去除以B,如果得到的商不是0就输出,否则就*10+下一位,直到最后的数为余数~ #include <iostream> using namespace std; int main() { string s; 阅读全文
posted @ 2020-06-18 08:52 chstor 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 1013 数素数 (20分) 测试点4就是素数可能超出10000这个大小,所以设置大点,例如:105000 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstrea 阅读全文
posted @ 2020-06-17 08:17 chstor 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1007 素数对猜想 (20分) 注意这个条件 i+2<=n ,不然会超出范围 #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<st 阅读全文
posted @ 2020-06-17 08:14 chstor 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 1003 我要通过! (20分) 得出重要结论:p*(t-p-1)==s.length()-1-t #include<iostream> #include<map> using namespace std; int main(){ int n;cin>>n; while(n--){ int t=0, 阅读全文
posted @ 2020-06-16 06:56 chstor 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 1049 数列的片段和 (20分) #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<string> #include<cstdio> 阅读全文
posted @ 2020-06-15 13:37 chstor 阅读(145) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页