随笔分类 -  ACM

上一页 1 2 3 4 5 6 7 ··· 36 下一页
大二到大三不堪回首的记忆....
摘要:原题链接 考察:枚举+二分 思路: 枚举其他两个药品的使用量,二分最后的使用量 ##Code #include <iostream> #include <cstring> #include <cmath> #include <vector> using namespace std; typedef 阅读全文
posted @ 2021-07-27 21:20 acmloser 阅读(38) 评论(0) 推荐(0)
摘要:原题链接 考察:枚举 思路: 预处理平方,分斜边和直角边,两个直角边两种情况处理. ##Code #include <iostream> #include <cstring> #include <cmath> #include <vector> using namespace std; typede 阅读全文
posted @ 2021-07-27 20:43 acmloser 阅读(34) 评论(0) 推荐(0)
摘要:原题链接 考察:组合数学+思维 思路: 如果只考虑一行的和是比较容易想到的:假设该行对应的$s$为$x$,如果$a%x==0$,那么求出$sum = \frac$的个数即可.如果有多行,就统计多行的和$x$.我们直接统计和的个数即可. 特判$!a$的情况,此时只要一个因子为0,其他任意值. ##Co 阅读全文
posted @ 2021-07-27 09:47 acmloser 阅读(55) 评论(0) 推荐(0)
摘要:原题链接 考察:数论 思路: 如果先手胜,说明$n$是一个质数或者$n$存在因子,该因子只有质因数.第二个条件判断只需要$n$有两个质因子,而不需要一个个枚举因数. ##Code #include <iostream> #include <vector> #include <cmath> using 阅读全文
posted @ 2021-07-27 08:27 acmloser 阅读(39) 评论(0) 推荐(0)
摘要:原题链接 考察:暴力枚举 思路: 记这道题的唯一意义是: 逆时针旋转90度后x'=-y,y=x 逆时针旋转180度后x'=-x,y=-y 逆时针旋转270度后x'=y,y=-x ##Code #include <iostream> #include <cstring> #include <algor 阅读全文
posted @ 2021-07-26 20:38 acmloser 阅读(39) 评论(0) 推荐(0)
摘要:原题链接 考察:枚举,思维 思路: 不论怎么取,都存在一个间隔点:左边的都是左手拿的,右边的都是右手拿的,枚举间断点,可以发现根据取的个数不同,由于贪心是尽可能间隔取,然后再计算连续的附加值. ##Code #include <iostream> #include <cstring> using n 阅读全文
posted @ 2021-07-26 09:51 acmloser 阅读(39) 评论(0) 推荐(0)
摘要:原题链接 考察:贪心 思路: 每$k-1$个间隔放,有多就从前往后放.有一些坑点要注意: $n%k$的位置和间隔的位置可以放置$m$个,这时需要特判$res$的初始值. 不能直接用左移运算符算加倍的结果.... ##Code #include <iostream> #include <cstring 阅读全文
posted @ 2021-07-25 21:26 acmloser 阅读(49) 评论(0) 推荐(0)
摘要:原题链接 考察:组合数学 错误思路: DFS枚举 正确思路: 直接枚举长度是$106$的数是不可能的.但是注意到和很小,最多是$9*106$.假设$x$个$a$,则有$n-x$个$b$,如果当前和合法,那么就是两个数添位置的简单组合数学 ##Code #include <iostream> #inc 阅读全文
posted @ 2021-07-25 19:09 acmloser 阅读(32) 评论(0) 推荐(0)
摘要:原题链接 考察:贪心(?) 思路: 不存在回文子串的条件是对于任意$i$,均有: $$s[i]!=s[i-1] , s[i] != s[i-2] $$ DFS枚举每一个修改的值. ##Code #include <iostream> #include <cstring> using namespac 阅读全文
posted @ 2021-07-25 15:08 acmloser 阅读(31) 评论(0) 推荐(0)
摘要:原题链接 考察:数论 思路: 串联: \(\frac{a}{b}+1 = \frac{a+b}{b}\) 并联: \(\frac{a}{b}与1并联--> \frac{a}{a+b}\) 也就是说分子分母不论大小可以得到相同的结果 ##Code #include <iostream> #includ 阅读全文
posted @ 2021-07-24 15:52 acmloser 阅读(44) 评论(0) 推荐(0)
摘要:原题链接 考察:DFS 思路: $mod[i]$维护$i$结点是否被修改,$anc[i]$记录$i$结点的父节点的父节点是谁.直接一次DFS即可同时求出两个值. ##Code #include <iostream> #include <cstring> #include <vector> using 阅读全文
posted @ 2021-07-24 10:51 acmloser 阅读(42) 评论(0) 推荐(0)
摘要:原题链接 考察:双指针 思路: 将原数组排序后,枚举每一个$a[i]\(,求使\)(j,i)$全部变为$a[i]$的最长左边界$j$,当$a[i]$变小时,$j$只会往更左扩展. ##Code #include <iostream> #include <cstring> #include <algo 阅读全文
posted @ 2021-07-24 09:34 acmloser 阅读(34) 评论(0) 推荐(0)
摘要:原题链接 考察:思维 思路: 设和为$sum$,每次减少$n-1$,最多进行$\frac{sum+n-2}$次.但是存在$a[i]$彼此相差悬殊的情况.此时答案为$max(a[i])$. ##Code #include <iostream> #include <cstring> using name 阅读全文
posted @ 2021-07-24 00:10 acmloser 阅读(49) 评论(0) 推荐(0)
摘要:原题链接 考察:线性dp 思路: 想到了但三重循环以为会超时,实际是只有$j=1$时才有三重循环. ##Code #include <iostream> #include <cstring> using namespace std; const int N = 1010; int n,m,x,y,c 阅读全文
posted @ 2021-07-23 13:07 acmloser 阅读(57) 评论(0) 推荐(0)
摘要:原题链接 思路: 结论题,排序奇偶分组,均分,没想出怎么证明 ##Code #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 100010; int n,sum 阅读全文
posted @ 2021-07-23 11:00 acmloser 阅读(26) 评论(0) 推荐(0)
摘要:原题链接 考察:思维 or 搜索 错误思路: 二分模拟,精度爆炸 正确思路一: 搜索....我是fw 正确思路二: 双指针设置$l = 1,r = n$,如果$s[i]==l$,说明右边不会在有人,$s[i]==r$左边不会在有人. ##Code #include <iostream> #inclu 阅读全文
posted @ 2021-07-23 09:44 acmloser 阅读(36) 评论(0) 推荐(0)
摘要:原题链接 考察:贪心 思路: 死于读不懂题,对于每个仓库,求裁判到它的距离,排序,两类仓库分开求,因为题目是这么说的 ##Code #include <iostream> #include <cstring> #include <cmath> #include <queue> using names 阅读全文
posted @ 2021-07-23 01:10 acmloser 阅读(54) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 36 下一页