D. GukiZ and Binary Operations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of l…
题目地址:http://codeforces.com/contest/551/problem/D 分析下公式能够知道,相当于每一位上放0或者1使得最后成为0或者1.假设最后是0的话,那么全部相邻位一定不能全是1,由于假设有一对相邻位全为1,那么这两个的AND值为1.又由于OR值是仅仅要有1.结果就为1.所以这位结果肯定为1.所以就推出了一个dp转移方程.dp[i][j]表示第i位上的数为j时的总个数.那么有: dp[i][0]=dp[i-1][0]+dp[i-1][1]; dp[i][1]=dp…
得到k二进制后,对每一位可取得的方法进行相乘即可,k的二进制形式每一位又分为2种0,1,0时,a数组必定要为一长为n的01串,且串中不出现连续的11,1时与前述情况是相反的. 且0时其方法总数为f(n) = f(n-1) + f(n-2),其中f(2) = 3,f(1) = 3. #include <bits/stdc++.h> using namespace std; #define ll long long ll n,k; int l,m; unsigned ]; queue<int…
题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following pr…
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <string> #include <iostream> #include <queue> #include <map> #include <vector>…
Problem D. GukiZ and Binary Operations Solution 一位一位考虑,就是求一个二进制序列有连续的1的种类数和没有连续的1的种类数. 没有连续的1的二进制序列的数目满足f[i]=f[i-1]+f[i-2],恰好是斐波那契数列. 数据范围在10^18,用矩阵加速计算,有连续的1的数目就用2^n-f[n+1] 最后枚举k的每一位,是1乘上2^n-f[n+1],是0乘上f[n+1] 注意以上需要满足 2^l>k.并且这里l的最大值为64,需要特判. #inclu…
E. GukiZ and GukiZiana Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/E Description Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. For given a…
C. GukiZ hates Boxes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/C Description Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there…
A. GukiZ and Contest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/A Description Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has de…
C. GukiZ hates Boxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In to…
E. GukiZ and GukiZiana time limit per test 10 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. F…
题目地址:http://codeforces.com/contest/551/problem/E 将n平均分成sqrt(n)块,对每一块从小到大排序,并设置一个总体偏移量. 改动操作:l~r区间内,对两端的块进行暴力处理,对中间的总体的块用总体偏移量标记添加了多少.时间复杂度: O(2*sqrt(n)+n/sqrt(n)). 查询操作:对每一块二分.查找y-总体偏移量.找到最左边的和最右边的.时间复杂度:O(sqrt(n)*log(sqrt(n))). 代码例如以下: #include <ios…
题目传送门 /* 题意:任意排列第一个字符串,使得有最多的不覆盖a/b字符串出现 字符串处理/贪心:暴力找到最大能不覆盖的a字符串,然后在b字符串中动态得出最优解 恶心死我了,我最初想输出最多的a,再最多的b,然而并不能保证是最多的:( */ #include <cstdio> #include <cstring> #include <string> #include <iostream> #include <algorithm> #includ…
题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <…
D. GukiZ and Binary Operations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of l…
B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/B Description Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a,…
题意与分析(CodeForces 551B) 这他妈哪里是日常训练,这是日常弟中弟. 题意是这样的,给出一个字符串A,再给出两个字符串B,C,求A中任意量字符交换后(不限制次数)能够得到的使B,C作为子串不重叠且出现次数最多的串. 看起来很简单对吧,做法也很简单,先排序字符,然后枚举合法的B串能在A串中出现的次数,看能有几个C串,然后求个最优解就行了.是不是很简单?然后WA了十几发,各种捉bug,太杀妈了. 这份代码看起来贼简单,这是我写的第三版了.... 这种字符串题目太苦手了QAQ 代码 #…
A. GukiZ and Contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now,…
Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a, b, and c. He wants to obtain string k by swapping some letters in a, so that k should contain as many non-overlapping…
题目链接:http://codeforces.com/problemset/problem/711/D D. Directed Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon has explored Udayland for quite some…
D. Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia…
题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P\) 点 的直线, 然后可以在这条直线上等概率选择一个在 \(S\) 中的点 \(v\) . 如果有多条直线 , 那么等概率选择任意一条 . (可以原地不动) 2 选择了这个点 \(v\) 后 , 将 \(P\) 移动到这个点 . 也就是只有第一次可以自己随机选择点 , 后面等概率随机移动 \(P\…
A. Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Simon has a rectangular table consisting of n rows and m columns. Simon numbered the rows of the table from top to bottom starting f…
题意:给定节点数n和所有节点的深度总和d,问能否构造出这样的二叉树.能,则输出“YES”,并且输出n-1个节点的父节点(节点1为根节点). 题解:n个节点构成的二叉树中,完全(满)二叉树的深度总和最小,单链树(左/右偏数)的深度总和最大.若d在这个范围内,则一定能构造出来:否则一定构造不出来. 1.初始构造一颗单链树,依次把底部的节点放入上面的层,直到满足深度总和为d 2.若当前深度总和sum > d,则先拿掉底端节点. 拿掉后,若sum依然比d大,就直接把底端节点放入有空位的最上层: 拿掉后s…
传送门:cf1395C 题意 c[i]=a[i]&b[j],b[j]是b数组中任意一个,求c[1] | c[2] | ... | c[n]最小值. 题解 经典的二进制枚举答案,因为a和b的最大值<29 ,所以最后的结果最大是9个位置全1,不会超过210 ,故只要枚举0到210-1即可.每次答案和a[i]&b[j]的值相与,如果有一个 j 可以使相与后答案不变,那么当前a[i]可以,如果没有,那么当前答案不可以.当所有a[i]都可行,输出答案,否则继续枚举. 代码 1 #include…
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…