上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 67 下一页
摘要: 设$minh$为$n$座山峰高度的最小值,$maxh$为$n$座山峰高度的最大值。 枚举最终调整后的最低峰的高度为$k$,则最高峰的高度为$k+17$,对于低于最终最低峰高度的山峰或高于最终最高峰高度的山峰,对他们进行调整。 const int N=1010; int h[N]; int n; in 阅读全文
posted @ 2021-05-02 22:04 Dazzling! 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 最裸的暴力,时间复杂度:\(O(n^3)\)。 const int N=110; int a[3],b[3]; int n; bool check(int c[],int a[]) { for(int i=0;i<3;i++) if(abs(a[i]-c[i]) > 2 && abs(a[i]-c[ 阅读全文
posted @ 2021-05-02 18:33 Dazzling! 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 给定$k$块木板来覆盖一些区间,希望$k$块木板的总长度最小。 先假设只有一块木板从编号最小的牛棚一直铺到编号最大的牛棚,然后选取$k-1$个区间将一块木板分成$k$块木板。 贪心策略:优先断开相邻编号差较大的区间。 const int N=210; int a[N],b[N]; int n,m,k 阅读全文
posted @ 2021-04-30 21:29 Dazzling! 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 首先写了个较为暴力的代码。 const int N=1010; bool sex[N]; double sum[N][N]; int n,m; void print(int a,int b) { if(!sex[a]) cout<<'-'; cout<<a<<' '; if(!sex[b]) cou 阅读全文
posted @ 2021-04-24 11:35 Dazzling! 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 开个桶进行统计,老套路了。 const int N=10010; struct Node { int id; int cnt; int money; bool operator<(const Node &W) const { if(money != W.money) return money > W 阅读全文
posted @ 2021-04-24 11:18 Dazzling! 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 模拟。 注意点 所有未与 E 记录配对的 S 记录以及未与 S 记录配对的 E 记录都必须忽略。 const int N=1010; struct Node { int st_tim; int ed_tim; }a[N]; bool borrow[N]; int n; int calc(int hh 阅读全文
posted @ 2021-04-24 11:07 Dazzling! 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点 .,还必须既有字母也有数字。 输入格式: 输入第一行给出一个正整数 N(≤ 100),随后 N 行,每行给出一个用户设置的密码,为不超过 80 个字符的 阅读全文
posted @ 2021-04-23 22:10 Dazzling! 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 模拟除法的过程就好了,并不需要高精度了。 int main() { int x; cin>>x; int r=0; int cnt=0; bool first=true; while(true) { r=r*10+1; cnt++; if(first && r/x) // 第一个不为0的商作为最高位 阅读全文
posted @ 2021-04-23 16:40 Dazzling! 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 题目保证不存在两个人是同名的。 找最近公共祖先使用向上标记法。 const int N=10010; unordered_map<string,string> fa; unordered_map<string,bool> sex; int n,m; bool check(string a,strin 阅读全文
posted @ 2021-04-22 22:17 Dazzling! 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 又是喜闻乐见的字符串题==。 int main() { int T; cin>>T; cin.ignore(); while(T--) { string s; getline(cin,s); vector<string> res; stringstream ss(s); string word; b 阅读全文
posted @ 2021-04-22 18:09 Dazzling! 阅读(90) 评论(0) 推荐(0) 编辑
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 67 下一页