题目链接 题意:给你三个数n,m,k;让你构造出一个nm的矩阵,矩阵元素只有两个值(1,-1),且满足每行每列的乘积为k,问你多少个矩阵. 解法:首先,如果n,m奇偶不同,且k=-1时,必然无解: 设n为奇数,m为偶数,且首先要满足每行乘积为-1,那么每行必然有奇数个-1,那么必然会存在有偶数个-1..满足每列乘积为-1,那么每列必然有奇数个-1,那么必然存在奇数个-1.互相矛盾. 剩下的就是有解的情况了. 我们可以在n-1m-1的矩阵中随意放置-1,1.在最后一列和最后一行控制合法性即可. #…
B. Ralph And His Magic Field time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on th…
Ralph is going to collect mushrooms in the Mushroom Forest. There are m directed paths connecting n trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the mushrooms on the path. The Mushroom Fore…
BC都被hack的人生,痛苦. 下面是题解的表演时间: A. QAQ "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of leng…
我感觉这场CF还是比较毒的,虽然我上分了... Problem A  QAQ 题目大意:给你一个由小写字母构成的字符串,问你里面有多少个QAQ. 思路:找字符串中的A然后找两边的Q即可,可以枚举找Q,也可以前缀和优化一下. #include<bits/stdc++.h> using namespace std; ]; ]; long long ans; int main() { scanf(); ); ;i<=n;i++) { sum[i]=sum[i-]; if(s[i]=='Q')…
A.QAQ 题目大意:从给定的字符串中找出QAQ的个数,三个字母的位置可以不连续 思路:暴力求解,先找到A的位置,往前扫,往后扫寻找Q的个数q1,q2,然 后相乘得到q1*q2,这就是这个A能够找到的QAQ个数,依次累加即可 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin>>s;…
| [链接] 我是链接,点我呀:) [题意] 给你一个n*m矩阵,让你在里面填数字. 使得每一行的数字的乘积都为k; 且每一列的数字的乘积都为k; k只能为1或-1 [题解] 显然每个位置只能填1或-1 如果只考虑前n-1行和前m-1列. 那么我们对这(n-1)*(m-1)的范围. 先任意填入数字; 则一共有\(2^{(n-1)*(m-1)}\)种方法. 然后把最后一行的前m-1列填一下. 使得前m-1列满足,每一列的乘积为k 然后把最后一列的前n-1行填一下使前n-1行每一行的乘积都为k 最后…
A.很水的题目,3个for循环就可以了 #include <iostream> #include <cstdio> #include <cstring> using namespace std; ]; int main() { cin>>str; ; int L = strlen(str); ; i < L; i++) ; j < L; j++) ; k < L; k++) if(str[i] == 'Q' && str[j…
现在有一个长度为n的数列 n不超过4000 求出它的gcd生成set 生成方式是对<i,j> insert进去(a[i] ^ a[i+1] ... ^a[j]) i<=j 然而现在给你了set 规模m<=1000 求原数列或check不可行 可以想到set中的max数字一定是原数列中的max , min数字一定是所有数字的因子 然而这样就走不下去了,没法通过枚举n或者什么来确定是否存在 一通乱想之后想出来了奇妙的解法.. 解:最小的数字为x 那么原数列中所有的数字都是x的倍数 它们…
C. Marco and GCD Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a dream Marco met an elderly man with a pair of black glasses. The man told him the key to immortality and then…