题目链接: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/C 题意 有 $m$ 种花,每种花数量无限,第一次购买一种花收益为 $a_i$,之后每一次购买收益为 $b_i$,问买 $n$ 朵花的最大收益为多少. 题解 感觉是个 $dp$,实际上是个贪心. 一定是一种花买了很多,其他花不买或只买一次,当其他花第一次购买的收益 $a_j$ 大于要买较多花的 $b_i$ 时,可以将一个 $b_i$ 换为其他花的 $a_j$ . 枚举哪种花买的较多,然后在 $a$…
题目链接:https://codeforces.com/contest/1379/problem/A 题意 给出一个由 '?' 和小写字母组成的字符串,可以将 '?' 替换为小写字母,判断是否存在一种替换方案使得字符串只包含一个 'abacaba' 子串. 题解 首先计算原字符串中所求子串的个数: 如果个数多于一,则不存在满足要求的替换方案 如果个数等于一,将所有 '?' 替换为 'abc' 外的字母即可 如果个数少于一,判断是否有可以替换的子串,以及替换后是否只有一个子串,如 'abaca?a…
这道题可以暴力的一直按要求的方法去做,做1000000次还不能整除m就认为永远不能整除m了(m不超过100000,循环1000000次比较安全了已经).这种方法可以AC. 下面深入的分析一下到底循环多少次就可以确定结果:首先有这样一个规律:(a+b)%c=(a%c+b%c)%c,那么这样其实这道题每次就是2*a.官方题解说的好: Production will stops iff exists integer K ≥ 0 such a·2K is divisible by m. From thi…
E. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's…
C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar…
C. Tile Painting Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate. The path consists of…
A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number th…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…