Codeforces Round #447】的更多相关文章

题目链接 题意:给你三个数n,m,k;让你构造出一个nm的矩阵,矩阵元素只有两个值(1,-1),且满足每行每列的乘积为k,问你多少个矩阵. 解法:首先,如果n,m奇偶不同,且k=-1时,必然无解: 设n为奇数,m为偶数,且首先要满足每行乘积为-1,那么每行必然有奇数个-1,那么必然会存在有偶数个-1..满足每列乘积为-1,那么每列必然有奇数个-1,那么必然存在奇数个-1.互相矛盾. 剩下的就是有解的情况了. 我们可以在n-1m-1的矩阵中随意放置-1,1.在最后一列和最后一行控制合法性即可. #…
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.很水的题目,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…
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…
A. QAQ time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Dia…
QAQ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> using std::vector; using std::sort; int cmp(const void * x, const void * y) { //x < y #define datatype int : -; #undef dataty…
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…
| [链接] 我是链接,点我呀:) [题意] 给你一个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 最后…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] C语言程序练习题 [代码] #include <bits/stdc++.h> using namespace std; string s; int main(){ #ifdef LOCAL_DEFINE freopen("F:\\c++source\\rush_in.txt", "r", stdin); #endif ios::sync_with_stdio(0),cin.tie(0);…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把gcd(a[1..n])放在输入的n个数之间. [代码] /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the solution is right? At least,the main ideal 4.use the puts("")…
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…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 思路:水. #include <set> #include <map> #include <stack> #include <queue> #includ…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了. A 水题 //#pragma comment(linker, "/STACK:102400000,102400000") #include<cstdio> #include<cmath> #include<iostream> #include<…
Codeforces Round #270 1003 C. Design Tutorial: Make It Nondeterministic time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A way to make a new task is to make it nondeterministic or probabili…
Codeforces Round #270 1002 B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One way to create a task is to learn from life. You can choose some experience…
Codeforces Round #270 1001 A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One way to create a task is to learn from math. You can generate some random m…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再看自己的代码发现有清晰的思维是多重要 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include…
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >> n; string str; cin >> str; , x = ; ; i < n ; ++ i){ if(str[i] == 'B') cnt+=(x << i); } cout<<cnt<<endl; }   Codeforces Round…