题目链接:https://codeforces.com/contest/1379/problem/C 题意 有 $m$ 种花,每种花数量无限,第一次购买一种花收益为 $a_i$,之后每一次购买收益为 $b_i$,问买 $n$ 朵花的最大收益为多少. 题解 感觉是个 $dp$,实际上是个贪心. 一定是一种花买了很多,其他花不买或只买一次,当其他花第一次购买的收益 $a_j$ 大于要买较多花的 $b_i$ 时,可以将一个 $b_i$ 换为其他花的 $a_j$ . 枚举哪种花买的较多,然后在 $a$…
题目传送门 /* 题意:求一个点为根节点,使得到其他所有点的距离最短,是有向边,反向的距离+1 树形DP:首先假设1为根节点,自下而上计算dp[1](根节点到其他点的距离),然后再从1开始,自上而下计算dp[v], 此时可以从上个节点的信息递推出来 */ #include <cstdio> #include <cstring> #include <cmath> #include <vector> using namespace std; ; const in…
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), giving the distances at which t…
D. Choosing Capital for Treeland time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Over…
题目链接:https://codeforces.com/contest/1379/problem/B 题意 给出三个正整数 $l,r,m$,判断在区间 $[l,r]$ 内是否有 $a,b,c$ 满足存在正整数 $n$,使得 $n \cdot a + b - c = m$ . 题解 最容易想的一种情况是: \begin{equation} {\lfloor \frac{m}{a} \rfloor} \cdot a + m\ \%\ a = m  \end{equation} 令 $b = l +…
题目链接:https://codeforces.com/contest/1379/problem/A 题意 给出一个由 '?' 和小写字母组成的字符串,可以将 '?' 替换为小写字母,判断是否存在一种替换方案使得字符串只包含一个 'abacaba' 子串. 题解 首先计算原字符串中所求子串的个数: 如果个数多于一,则不存在满足要求的替换方案 如果个数等于一,将所有 '?' 替换为 'abc' 外的字母即可 如果个数少于一,判断是否有可以替换的子串,以及替换后是否只有一个子串,如 'abaca?a…
给定n k以及n个人已参加的比赛数,让你判断最少还能参加k次比赛的队伍数,每对3人,每个人最多参加5次比赛 #include <iostream> using namespace std; int main(){ ; cin >> n >> k; ; i < n; ++ i){ int a; cin >> a; ) cnt ++; } cout<<cnt/<<endl; }…
time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the…
D. Fish Weight 题目连接: http://www.codeforces.com/contest/298/problem/D Description It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number.…