Problem - C - Codeforces 看清题目要求, 最重要部分在第二段. 大佬最后给出的代码果然简单, 思路简单化, 未必非要把答案在一个大括号里全部完成, 两个指针同时跑,中间加了一堆判断处理, 反而不如返璞归真, 简单清晰为后面改代码也省了很多力气 AC代码 #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const int N = 2e5+10…
& -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 226732710 题意 t个测试样例,在每个样例中 数组有n个数,数字范围[ 0, 2k - 1] 使得数组每个数&后,结果=0,并且这n个数的和要尽量大 输出有多少个这样的数组 解析 数组每个数&后,结果=0  -->每一位至少一个0 数要尽量大  -->只要这一位可以 != 0, 就…
A. Three swimmers 题意:第一个人跳水是每隔a分钟去一次,第二个人跳水是每隔b分钟,第三个人跳水是每隔c分钟,一个人准备在p分钟的 时候去跳水,问需要最少等待多长时间才能轮到前三个人 思路:数学公式进行找,从头到尾挨个人找就行不用混着,混着也没有办法下手 当时:1)当时想着从头开始然后一直用while循环,根本想不到用数学公式,也没有想到是分开来计算的 代码: 1 #include<iostream> 2 #include<algorithm> 3 #include…
The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c). Over time the stars twinkle. At moment 0 the i-th…
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decided to h…
n people are standing on a coordinate axis in points with positive integer coordinates strictly less than 106. For each person we know in which direction (left or right) he is facing, and his maximum speed. You can put a bomb in some point with non-n…
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n个字符, 数字与字符一一对应, 其中字符R红色代表数字可以上升, B蓝色代表可以下降, 问一顿操作下来能否使n个数含有1~n的所有数 题解 当时真的没想到, 蓝色一定在数组前面, 红色一定在数组后面,( 反正就算有方案使得蓝不在前面, 红不在后面,蓝红也是可以交换的). 排序后, 前面的蓝色数字如果…
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 1005 using namespace std; char a[maxn][maxn]; int ans; void solve…
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around the abandoned Eikou Cram School building, Oshino's makeshift residence. The space is represented by a rectangular grid of n × m cells, arranged into n…
— This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewher…
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this. The phoenix has a rather long lif…
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows. A positive integer n is decided first. Both Koyomi a…
Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th number is the total number of non-empty substrings of s which are k-palindromes. A string is 1-palindrome if and only if it reads the same backward as f…
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The secon…
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one.. There is a glob pattern in the statements (a string consis…
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules…
http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开始到倒数第二项,当前的a[i]=(a[i-1],a[i],a[i+1])三项排序后的中间项,比如连续3项为 1 0 1,那么中间的就变为1,然后题目让你输出达到稳定状态时所需的最小步数,不能的话输出-1. 无论给你啥数列,都能达到稳态.所以不可能输出-1: 还有一开始就稳定不变,或经过几次变换而稳定…
Problem - B - Codeforces 就是给你个序列, 给他整成升序的, 每次操作可以使相邻两个数交换位置, 交换条件是二数之和为奇数 结果只需输出是否可以整成升序的 思路: 需要奇数偶数分开讨论, 如果奇数和偶数都分别是单增的那么可行, 反之为no #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N = 1e…
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利用二进制, 第i位为1则加上a[i], 为0则不加, #include<iostream> #include <algorithm> #include <cmath> #include<map> using namespace std; typedef long…
Problem - A - Codeforces 题目 题意很简单每次操作可以使得a1 a2  a3任意两个数分别+1  -1 求最后使得a+c-2b绝对值的最小值 BUG就是最后忽略了-2和2这一点, 他们再进行一次操作就可以变成1和-1, 最后的绝对值也就是1, 所以最后的答案没有2  ! ! ! 官方代码 #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin…
Problem - D1 - Codeforces 题意: 给n个符号(+或-), +代表+1, -代表-1, 求最少删去几个点, 使得     题解(仅此个人理解): 1. 这题打眼一看, 肯定和奇偶有关系, 奇数为+, 偶数为-, 但是删去点这一操作是动态的, 删去某点后, 后面的点的正负随之颠倒, 即奇数位+变偶数位-, 偶数位-变奇数位+, 恰好可以利用该特质 也就是说可以这样理解: 找到一个位置,删去该点并使得后面的点正负颠倒, 最后满足条件. 2. 对于奇数个数, 必须变成偶数个个数…
A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, i…
C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a…
Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change. You h…
简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include <iostream> #include <algorithm> using namespace std; int main(){ int i, j, k, t, n; int num, flag, ans; ]; scanf("%s",a); scanf("%d…
题目意思: 给长度为n(n<=2000)的数字串,数字只能为1或者2,可以将其中一段区间[l,r]翻转,求翻转后的最长非递减子序列长度. 题解:求出1的前缀和,2的后缀和,以及区间[i,j]的最长不递增子序列. f[i][j][0]表示区间i-j以1结尾的最长不递增子序列: f[i][j][1]表示区间i-j以2结尾的最长不递增子序列,显然是区间i-j 2的个数: 所以转移方程为: f[i][j][1] = f[i][j-1][1] + (a[j]==2);   f[i][j][0] = max…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 肯定用尽量多的4最好. 然后对4取模的结果 为0,1,2,3分类讨论即可 [代码] #include <bits/stdc++.h> using namespace std; int fix(int x) { int t = x/4; int rest = x%4; if (rest==0) return t; if (rest==1) { if (t>=2) { t-=2; }else return -1; t++;…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] k=1的时候就是最小值, k=2的时候,暴力枚举分割点. k=3的时候,最大值肯定能被"独立出来",则直接输出最大值 [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e5; int a[N+10],n,k,premi[N+10],aftermi[N+10]; int main() {…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“-1”. 数据范围: 1 ≤ n ≤ 100, 2 ≤ t ≤ 10 so easy!首先考虑无解的时候,只有当n==1,t==10是无解,其他情况都存在解.很容易想到最简单的n位数能被t整除的数是,t个n组成的数. 参考代码: By Royecode, contest: Codeforces Ro…