D. Vasya And The Matrix time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Now Vasya is taking an exam in mathematics. In order to get a good mark, Vasya needs to guess the matrix that the teache…
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforces.com/contest/1016/problem/C 题意: emmm,说不清楚,还是直接看题目吧. 题解: 这个题人行走的方式是有一定的规律的,最后都是直接走到底,然后从另外一行走回来.并且通过画图观察,会发现他走到格子的时间会有一定的规律. 所以就维护几个前缀和就行了,从1到n枚举一下,还要…
D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Now Vasya is taking an exam in mathematics. In order to get a good mark, Vasya needs to guess the matrix that the te…
题目地址 Edu48 A.Death Note 翻译 你有一个无穷页的本子,每一页可以写\(m\)个名字, 你在第\(i\)天要写\(a_i\)个名字,如果这一页恰好写满了,你就会翻页, 问每天的翻页次数. 题解 傻逼题,求个前缀和,然后除\(m\)计算前缀翻页次数,再和前面一天减一下就好. 代码 #include<cstdio> #define ll long long #define MAX 200200 inline int read() { int x=0;bool t=false;c…
[链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时异或一下a1^b1 b1^a2^a3...^an =a1^b2^...^bn 我们设x=b1^a2^a3...^an =a1^b2^...^bn 然后我们就能得到一个符合要求的矩阵了 会发现第一列的异或和就是b1.第一行的异或和就是a1 因为x同时可以写成上面的那两种形式 第2到第n行以及第2到第m…
EDU #48 D 题意:给定一个矩阵,已知每一行和每一列上数字的异或和,问矩阵上的数字是多少,不存在则输出NO. 思路:构造题,可以考虑只填最后一行,和最后一列,其中(n,m)要特判一下.其他格子给0即可. 自己之前接触这类题目较少,感觉写这种题,自己的智商都提高了. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <stri…
A. Vasya and Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya is reading a e-book. The file of the book consists of nn pages, numbered from 11 to nn. The screen is currently disp…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易. 然后蛇形走位之后走到最右再掉头的这个过程也能倒推出来. 考虑sum[i]和sum[i+1]的转移就好 显然sum[i]只是多了a[i]和b[i]两个格子. 考虑它们的贡献就好. sum[i]表示从i开始一直走到右,然后再走到左的花费.(且i位置作为t=0 (之后只要把i后面的和乘上之前过的时间e…
http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法   为什么我做了那么多讨论,原因是没注意这个: 标记 最后一个字符,同时注意 l+m-3. 特殊情况就 vis 0000011111111111112 s1  abaccabaacabacabacca      红色的地方是 l 和 r ,为了防止在 l 处计数多了就得 l + m - 3 s2  abacca we[s+m-1…
B. Segment Occurrences time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given two strings s and t , both consisting only of lowercase Latin letters. The substring s[l..r] is the str…
题:https://codeforces.com/contest/1016/problem/D 题意:有一个 n * m 的矩阵, 现在给你 n 个数, 第 i 个数 a[ i ] 代表 i 这一行所有数的抑或和. 再给你 m 个数, 第 i 个数 b[ i ] 代表 i 这一列 所有数的抑或和. 问你是否能 构造出任意一个满足条件的矩阵, 不能输出 NO, 能输出YES 和那个 矩阵. 分析:考虑yes和no的情况,yes当且仅当,行的全部异或和等于列的全部异或和 原因:行的全部异或和x,就是…
A. Death Note time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last…
题意:求满足条件的(i,j)对数:\(gcd(v,a_i)=x,lcm(v,a_j)=y\) 题解:\(x|a_i,a_j|y\),\(x|y\),考虑质因子p,假设a_i中p次数为a,x中次数为b,y为c,\(a_j\)为d;a>=b,c>=d. 假设a>b,c>d,那么由于\(gcd(v,a_i)=x\),v中p的次数为b,由于\(lcm(v,a_j)=y\),那么\(max(b,d)==c\),又c>d,所以b=c<a和x|y矛盾,所以此时ij不满足条件 其他情况…
A:https://www.cnblogs.com/myx12345/p/9843001.html B:https://www.cnblogs.com/myx12345/p/9843021.html C:https://www.cnblogs.com/myx12345/p/9936811.html D:https://www.cnblogs.com/myx12345/p/9936962.html E: F:https://www.cnblogs.com/myx12345/p/10065082.h…
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f(a, b) = 1 + f(a, b-gcd(a, b)); 求 f(a, b) , a,b <= 1e12 分析: b 每次减 gcd(a, b) 等价于 b/gcd(a,b) 每次减 1 减到什么时候呢,就是 b/gcd(a,b)-k 后 不与 a 互质 可先将 a 质因数分解,b能除就除,不能…
Educational Codeforces Round 40 (Rated for Div. 2) C. Matrix Walk time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is a matrix A of size x × y filled with integers. For every , *A**i, …
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. 输入 The only line contains odd integer n (1 ≤ n ≤ 49). 输出 Print n lines…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec Problem Description Input The input contains a single line consisting of 2 integers N and M (1≤N≤10^18, 2≤M≤100). Output Print one integer, the total n…
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best Subsegment 题意: 给出n个数,选取一段区间[l,r],满足(al+...+ar)/(r-l+1)最大,这里l<=r,并且满足区间长度尽可能大. 题解: 因为l可以等于r,所以我们可以直接考虑最大值,因为题目要求,直接求连续的最大值的长度就是了. 代码如下: #include <bits…
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contest/1107/problem/D 题意: 给出一个n*(n/4)的矩阵,这个矩阵原本是一些01矩阵,但是现在四个四个储存进二进制里面,现在给出的矩阵为0~9以及A~F,表示0~15. 然后问这个矩阵能否压缩为一个(n/x)*(n/x)的矩阵,满足原矩阵中大小为x*x的子矩阵所有数都相等(所有子矩阵构…
人生第二场codeforces.然而遇上了Education场这种东西 Educational Codeforces Round 40 下午先在家里睡了波觉,起来离开场还有10分钟. 但是突然想起来还没报名呢,并且电脑又是开机黑屏什么情况 莫非为之后的凉凉埋下了伏笔? 比赛之前联系了下余翱和叶可禾,似乎都要去切题的样子? 想到第一次有人一起打CF还是有点小激动的.于是果断屏蔽余翱QQ上的刷屏去看A题了. A. Diagonal Walking 非常仔细地把题读了一遍,然后……啥这不是字符串入门题…
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a text of single-space separated words, consisting of sm…
Educational Codeforces Round 67 CF1187B Letters Shop 二分 https://codeforces.com/contest/1187/submission/56313177 CF1187C Vasya And Array 直接构造 https://codeforces.com/contest/1187/submission/56316127 CF1187D Subarray Sorting 这题等System Test后更吧... CF1187E…
这场比赛没有打,后来补了一下,第五题数位dp好不容易才搞出来(我太菜啊). 比赛传送门:http://codeforces.com/contest/1073 A. Diverse Substring 题意:给你个字符串,让你找一个子串满足任意一个字符的个数不超过其他字符的总和,输出yes或no表示否存在,如果存在输出任意一个. 这题只要找两个不同的相邻字符,因为两个字符各一个都不超过其他字符的总和,如果字符串只由一个字符组成或长度等于一才会不存在. 代码如下: #include <iostrea…
Educational Codeforces Round 30  A. Chores 把最大的换掉 view code #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,no-stack-protector") #include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define endl "\n&quo…
Educational Codeforces Round 20  A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; fu…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R andx = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0. 输入 Th…
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal. 输入 The first line contains integer n (1 ≤ n ≤ 3·105)…
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and dis the row from '1' to '8'. Find the number of moves perm…