随笔分类 - 算法基础—暴力枚举/剪枝
摘要:#include <bits/stdc++.h> #define gcd(a, b) __gcd(a, b) #define INF 0x3f3f3f3f3f #define eps 1e-6 #define PI acos(-1.0) #define pb push_back #define fs
阅读全文
摘要:A. Era 维护一个新数组的末尾位置变量pos,遍历的时候不断更新即可。 #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <map> #include <set> #def
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/11259/K 来源:牛客网 题目描述 On a distant planet of dreams, Toilet-Ares is packing up the things and memories, ready to
阅读全文
摘要:Soroush and Keshi each have a labeled and rooted tree on 𝑛n vertices. Both of their trees are rooted from vertex 11. Soroush and Keshi used to be at
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/11258/H 来源:牛客网 题目描述 xay has an array a of length n, he wants to know how many triples (i, j, k) satisfy ai×aj=a
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/11213/I 来源:牛客网 题目描述 在游戏中,因为一次错误的决断,你的士兵被敌方实行围剿。为了挽回人员损失,你不得不开启金手指暂停敌方士兵的移动,从而尽量让自己的士兵能成功突围。 已知地图是一块n×mn×m的区域,每块
阅读全文
摘要:Suppose you have two points 𝑝=(𝑥𝑝,𝑦𝑝)p=(xp,yp) and 𝑞=(𝑥𝑞,𝑦𝑞)q=(xq,yq). Let's denote the Manhattan distance between them as 𝑑(𝑝,𝑞)=|𝑥𝑝−�
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/15329/F 来源:牛客网 题目描述 There’s a new art installation in town, and it inspires you... to play a childish game. The
阅读全文
摘要:You have a card deck of n cards, numbered from top to bottom, i. e. the top card has index 1and bottom card — index n. Each card has its color: the 𝑖
阅读全文
摘要:A. 回文括号序列计数 坑比题...注意回文的定义,并不是括号序列对称。比如(())不是回文的而))是回文的。而合法括号列左右两端一定是(和),必然非回文,因此只有空串答案是1. #include <iostream> using namespace std; #define mod 9982443
阅读全文
摘要:题目描述 译自 CEOI2015 Day2 T1「Ice Hockey World Championship」 今年的世界冰球锦标赛在捷克举行。Bobek 已经抵达布拉格,他不是任何团队的粉丝,也没有时间观念。他只是单纯的想去看几场比赛。如果他有足够的钱,他会去看所有的比赛。不幸的是,他的财产十分有
阅读全文
摘要:注意到“这一行中从第3个砝码开始,每个砝码的质量至少等于前面两个砝码(也就是质量比它小的砝码中质量最大的两个)的质量的和。” 斐波那契数列增长速度很快,大约n = 40的时候就到了int的最大值了,因此完全可以搜索。 注意剪枝! #include <iostream> #include <algor
阅读全文
摘要:A. Dense Array 数据范围很小可以直接枚举,对于每个间隔用while循环二倍二倍往里插。 #include <iostream> using namespace std; int a[55]; int main() { freopen("data.txt", "r", stdin); i
阅读全文
摘要:Educational Codeforces Round 104 (Rated for Div. 2) A~D A. Arena 除去最少的那部分以外都对答案有贡献。 #include <iostream> #include <algorithm> #include <set> using name
阅读全文
摘要:There are n people who want to participate in a boat competition. The weight of the i -th participant is wi. Only teams consisting of two people can p
阅读全文
摘要:Description Mr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to r
阅读全文
摘要:Lead of Wisdom In an online game, "Lead of Wisdom" is a place where the lucky player can randomly get powerful items. There are k types of items, a pl
阅读全文
摘要:https://www.jisuanke.com/contest/11360/challenges 其他题慢慢补 C. Pawn‘s Revenge You are playing a special chess game against a professor and you've almost
阅读全文
摘要: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
阅读全文
摘要:Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer nn , he encrypts
阅读全文