随笔分类 -  算法基础—二分

摘要:A. 智乃的Hello XXXX 随便输出Hello xxx即可。 B. 智乃买瓜 链接:https://ac.nowcoder.com/acm/contest/23478/B 来源:牛客网 题目描述 有一人前来买瓜。 “哥们儿,这瓜多少钱一斤呐” “两块钱一斤” “What's up,这瓜皮是金子 阅读全文
posted @ 2022-01-29 00:08 脂环 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Recently, Petya learned about a new game "Slay the Dragon". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you 阅读全文
posted @ 2021-09-22 11:03 脂环 阅读(119) 评论(0) 推荐(0) 编辑
摘要:在做一道题目的时候需要对C++的set进行二分查找,于是自然而然的使用了std::upper_bound,然而结果是在第36个测试点超时了,改了一天尝试了各种卡常剪枝均没有效果,最后即将要与标程逐字符一致的时候突然发现过了,原因就是标程用的是set自带的upper_bound函数。上网查阅资料发现对 阅读全文
posted @ 2021-08-08 15:52 脂环 阅读(2035) 评论(2) 推荐(3) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11255/J 来源:牛客网 题目描述 Bob has an n×mn×m matrix WW. This matrix is very special, It's calculated by two sequences 阅读全文
posted @ 2021-07-26 18:40 脂环 阅读(303) 评论(0) 推荐(0) 编辑
摘要:给定一位研究者论文被引用次数的数组(被引用次数是非负整数)。编写一个方法,计算出研究者的 h 指数。 h 指数的定义:h 代表“高引用次数”(high citations),一名科研人员的 h 指数是指他(她)的 (N 篇论文中)总共有 h 篇论文分别被引用了至少 h 次。且其余的 N - h 篇论 阅读全文
posted @ 2021-07-11 23:15 脂环 阅读(80) 评论(0) 推荐(0) 编辑
摘要:On a strip of land of length 𝑛n there are 𝑘k air conditioners: the 𝑖i-th air conditioner is placed in cell 𝑎𝑖ai (1≤𝑎𝑖≤𝑛1≤ai≤n). Two or more ai 阅读全文
posted @ 2021-07-11 11:51 脂环 阅读(154) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11176/C 来源:牛客网 题目描述 某个国家的货币体系里有 nn 种面值不同的纸币,从小到大面值分别是 a1,a2,...,ana1,a2,...,an,a1=1a1=1。 当取款人去 ATMATM 机取款 cc 元的 阅读全文
posted @ 2021-07-10 11:33 脂环 阅读(74) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/9984/B 来源:牛客网 题目描述 众所周知,武辰延很喜欢字符串。 这天,他对着两个字符串 s 和 t 发呆,他发现这两个串的前缀有很多相似的地方,s 的两个前缀连接起来竟也是 t 的前缀。 武辰延想知道有多少对 s 的 阅读全文
posted @ 2021-02-19 23:55 脂环 阅读(89) 评论(0) 推荐(0) 编辑
摘要:A. Dense Array 数据范围很小可以直接枚举,对于每个间隔用while循环二倍二倍往里插。 #include <iostream> using namespace std; int a[55]; int main() { freopen("data.txt", "r", stdin); i 阅读全文
posted @ 2021-02-18 11:05 脂环 阅读(143) 评论(0) 推荐(0) 编辑
摘要:https://ac.nowcoder.com/acm/contest/11746 好久没写过代码了,思维能力下降,爬了 A. 切蛋糕 待补 B. 小宝的幸运数组 套路题,初始化tmp为0,从头遍历一遍数组,用tmp加上当前a[i]再对k取模,如果有两个位置得到的模数一样,说明这一段的和就是k的倍数 阅读全文
posted @ 2021-01-30 20:33 脂环 阅读(178) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/9925/D 来源:牛客网 题目描述 As a world-famous traveler, Prof. Pang's research interest is to travel as many places as po 阅读全文
posted @ 2020-12-14 23:18 脂环 阅读(269) 评论(2) 推荐(1) 编辑
摘要:Binary Search Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After 阅读全文
posted @ 2020-10-25 00:36 脂环 阅读(404) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int a[1005][1005] = {0}, n, m; int main() { int t; cin >> t; while(t--) { memset(a, 0, sizeof(a)); cin > 阅读全文
posted @ 2020-07-22 22:08 脂环 阅读(752) 评论(0) 推荐(0) 编辑
摘要:Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly nn flowers. Vladimir went to a flower s 阅读全文
posted @ 2020-07-20 15:59 脂环 阅读(277) 评论(0) 推荐(0) 编辑
摘要:题目描述 S 城现有两座监狱,一共关押着 NNN 名罪犯,编号分别为 1−N1-N1−N。他们之间的关系自然也极不和谐。很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突。我们用“怨气值”(一个正整数值)来表示某两名罪犯之间的仇恨程度,怨气值越大,则这两名罪犯之间的积怨越多。如果两名怨气值 阅读全文
posted @ 2020-07-17 09:38 脂环 阅读(195) 评论(0) 推荐(0) 编辑
摘要:公交换乘共 20 个测试点 每个测试点 5 分每个测试点限时 1 秒 运行内存上限 256MB查看本题最近一次测评结果著名旅游城市 B 市为了鼓励大家采用公共交通方式出行,推出了一种地铁换乘公交车的优惠方案:1. 在搭乘一次地铁后可以获得一张优惠票,有效期为 454545 分钟,在有效期内可以消耗这 阅读全文
posted @ 2020-07-11 00:17 脂环 阅读(713) 评论(0) 推荐(0) 编辑
摘要:You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in 阅读全文
posted @ 2020-05-27 10:40 脂环 阅读(423) 评论(0) 推荐(0) 编辑
摘要:A card pyramid of height 11 is constructed by resting two cards against each other. For h>1h>1, a card pyramid of height hh is constructed by placing 阅读全文
posted @ 2020-05-11 23:58 脂环 阅读(316) 评论(0) 推荐(0) 编辑
摘要:题目背景 “咚咚咚……”“查水表!”原来是查水表来了,现在哪里找这么热心上门的查表员啊!小明感动的热泪盈眶,开起了门…… 题目描述 妈妈下班回家,街坊邻居说小明被一群陌生人强行押上了警车!妈妈丰富的经验告诉她小明被带到了 ttt 区,而自己在 sss 区。 该市有 mmm 条大道连接 nnn 个区, 阅读全文
posted @ 2020-04-17 11:41 脂环 阅读(276) 评论(0) 推荐(0) 编辑
摘要:题目描述 Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself. Recently 阅读全文
posted @ 2020-04-16 20:37 脂环 阅读(256) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
主题色彩