题目链接 题目大意: \(~~\)给定n个正整数和一个数k,问这n个数的阶乘之和能不能被k的阶乘整除 既:(a\(_{1}\)!+a\(_{2}\)!+a\(_{3}\)!+....+a\(_{n}\)!)\(~\)%\(~\)k!\(~\)==$~$0 题目分析: 我们把连续几个数的阶乘可以分解成如下结果: \(~~~\)假设现在有3个2,4个3: \(~~~\)那我们可以得到sum\(~\)=$~$3*2!+ 4*(3*2!) \(~~~~~~~~~~~~~~~~~~~~~~~~~\)sum…
Div1A / 2C. Make Nonzero Sum 令最后每个\(a_i\)的系数为\(c_i\)(\(c_i=1/-1\)),发现只要满足\(c_1=1\)(下标从1开始),且c中没有两个-1相连,就一定能找出一种划分方式.那我们先令所有\(c_i\)都为1,再进一步把一些1改成-1.如果全是1时序列的和sum已经是0,那么就已经找到一个答案了.否则我们只会把\(a_i=1/-1\)的位置的系数改成-1,当\(sum>0\)时改\(a_i=1\)的i的系数,否则改\(a_i=-1\)的i…
CodeForces1754 注:所有代码均为场上所书 Technical Support 解析: 题目大意 给定一个只包含大写字母 \(\texttt{Q}\) 和 \(\texttt{A}\) 的字符串,如果字符串里的每一个 \(\texttt{Q}\) 都能与在其之后的 \(\texttt{A}\) 一一对应地匹配,则输出字符串 \(\texttt{Yes}\),否则输出字符串 \(\texttt{No}\).注意,可以有 \(\texttt{A}\) 没有被匹配,但每个 \(\textt…
比赛链接 A 题解 知识点:枚举. 只要一个Q后面有一个A对应即可,从后往前遍历,记录A的数量,遇到Q则数量减一,如果某次Q计数为0则NO. 时间复杂度 \(O(n)\) 空间复杂度 \(O(1)\) 代码 #include <bits/stdc++.h> #define ll long long using namespace std; bool solve() { int n; cin >> n; string s; cin >> s; s = "?&qu…
C. Parity Game 题目连接: http://www.codeforces.com/contest/298/problem/C Description You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes…
B. Strings of Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/problem/C Description Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pair…
B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/B Description Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorit…
A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/A Description Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resista…
D. Directed Roads 题目连接: http://www.codeforces.com/contest/711/problem/D Description ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of n towns numbered from 1 to n. There are n directed roads…
C. Pythagorean Triples 题目连接: http://www.codeforces.com/contest/707/problem/C Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers…