codeforces 1096 题解】的更多相关文章

A: 发现最优的方案一定是选 $ l $ 和 $ 2 * l $,题目保证有解,直接输出即可 #include <bits/stdc++.h> #define Fast_cin ios::sync_with_stdio(false), cin.tie(); #define rep(i, a, b) for(register int i = a; i <= b; i++) #define per(i, a, b) for(register int i = a; i >= b; i--…
CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix \(M\) of size \(n \times n\) contains only 'X' and '.' (without quotes). The element in t…
12.18 update:补充了 $ F $ 题的题解 A 题: 题目保证一定有解,就可以考虑用 $ 2 $ 和 $ 3 $ 来凑出这个数 $ n $ 如果 $ n $ 是偶数,我们用 $ n / 2 $ 个 $ 2 $ 来凑出 $ n $ 即可 如果 $ n $ 是奇数,就用 $ n / 2 - 1 $ 个 $ 2 $ 和 $ 1 $ 个 $ 3 $ 凑出 $ n $ 即可 所以只需输出 $ n / 2 $ B 题: 如果一个字符串重排后一定是回文串,说明这个字符串只有 $ 1 $ 种字符 如…
这题只需要会10转P进制就行了. PS:答案需要约分,可以直接用c++自带函数__gcd(x,y). 洛谷网址 Codeforces网址 Code(C++): #include<bits/stdc++.h> using namespace std; int jz(int x,int p) { ,a; ) {//10转P进制 a=x%p; s+=a;//直接将算出的哪一位加上 x/=p; } return s; } int main() { ; cin>>A; ; ;i<A;i…
题面 传送门:http://codeforces.com/problemset/problem/691/E E. Xor-sequences time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given n integers a1,  a2,  …,  an. A sequence of integers x1,  x2…
题面 传送门:http://codeforces.com/problemset/problem/833/B B. The Bakery time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output Some time ago Slastyona the Sweetmaid decided to open her own bakery! She…
题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A year ago on the bench in public park Leha found an array of n numbers. L…
题面 传送门:http://codeforces.com/problemset/problem/515/C Drazil is playing a math game with Varda. Let’s define f(x)f(x)for positive integer x as a product of factorials of its digits. For example, f(135)=1!∗3!∗5!f(135)=1!∗3!∗5! First, they choose a dec…
题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q queries x1, -, xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, -, ar) = xi. 题目大意:…
题解 非常有意思的\(2-SAT\)的题. 听学长讲完之后感觉确实容易想到\(2-SAT\),顺理成章. 显然,对于两个串,对咱们来说有意义的显然是两个串中第一个不同的数字.那么,我们假设两个串分别是\(A,B\),第一个不同的位置是\(pos\),且\(A_{pos}=x,B_{pos}=y\),如果\(x>y\),那么显然我们需要给\(x\)加一个\('\),且\(y\)一定不能加,要不然没有意义.所以我们把\(x+m\)向\(y\)连边,反之就反着来就好了. 然后就可以跑一遍\(2-SAT…