A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/A Description Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros an…
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; int main(void) //Codeforce…
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 */ #include <cstdio> #include <algor…
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少步,按照这个次数之后的能否满足要求 题目读的好累:( */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath>…
C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/problem/C Description Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A…
B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/556/problem/B Description Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famou…
B. Case of Fugitive Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/problem/B Description Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost ful…
C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/problem/A Description Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of cont…
B. Case of Fugitive time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet a…
题目地址:传送门 这题尽管是DIV1的C. . 可是挺简单的. .仅仅要用线段树分别维护一下横着和竖着的值就能够了,先离散化再维护. 每次查找最大的最小值<=tmp的点,能够直接在线段树里搜,也能够二分去找. 代码例如以下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <…
You are given two positive integers aa and bb . In one move, you can change aa in the following way: Choose any positive odd integer xx (x>0x>0 ) and replace aa with a+xa+x ; choose any positive even integer yy (y>0y>0 ) and replace aa with a−…
C. A and B and Team Training time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A and B are preparing themselves for programming contests. An important part of preparing for a competition is s…
B. A and B and Compilation Errors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs t…
Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the follow…
A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing…
[感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typede…
题意与分析(CodeForces 556C) 为了将所有\(n\)个娃娃编号递增地串在一起(原先是若干个串,每个串是递增的), 我们有两种操作: 拆出当前串中最大编号的娃娃(且一定是最右边的娃娃). 连接一个单个的娃娃(不能和其他娃娃相连着的娃娃). 问最少操作次数,使得所有娃娃串在一起. 这题当时我是写的相当的痛苦,因为不太擅长这种优雅的思维题QAQ 首先有一点可以知道,如果一串的开头不是1,那么它一定要被整个拆开,操作次数也就是个数-1--这个我花了好久才想到:而如果该串的起点是1,那么它只…
B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of…
题意:有n-1个缝隙,在上面搭桥,每个缝隙有个ll,rr值,ll<=长度<=rr的才能搭上去.求一种搭桥组合. 经典问题,应列入acm必背300题中.属于那种不可能自己想得出来的题.将二元组[ll,rr]排序(ll相同时再rr),长度x排序(升序).一个全局优先队列pq(rr小的顶部).for循环,对每个x,将ll比它小的放入优先队列pq,如果pq仍为空,说明这块桥用不上,不为空,看top的rr是否大于x,如果大于,这块桥就能用上,并且给当前的top一定是可行的. 乱码: #pragma co…
题意:1-n的数字,大的在小的后面,以这种规则已经形成的几个串,现在要转为一个串,可用的操作是在末尾拆或添加,问要操作几次? 模拟了很久还是失败,看题解才知道是数学.看来这种只要结果的题,模拟很不合算. 设结果为res,res先为0,看1在的那个串,在后一位不等于前一位加1的地方断开.res+=剩下数量*2,因为剩下的都要拆掉,然后在某个时刻再装上去.对于其他的串,res+=(串长度-1)*2+1,因为最前面的数字不用拆,只要装. 乱码: #pragma comment(linker,"/STA…
题意:直角边为n的网格巧克力,一格为一块,选择斜边上一点,从左或上吃,直到吃到空气,称为一次操作.给出几个操作,问各能吃几块.如果x是当前要吃的横坐标,在已经吃过的中找x1>=x的第一个x1,即lower_bound().如果x1==x,结果就是0:否则假设x是往上吃,x1也是往上吃,因为x和x1间没有往左吃的,因此x1结束的地方也是x结束的地方.如果x往上吃,x1往左吃,因为x1横坐标最小,纵坐标最大,对x能吃到的位置仅受到它的影响. 乱码: //#pragma comment(linker,…
http://codeforces.com/problemset/problem/556/B 题意:给定n个数字且都小于n,然后每次循环第2k+1个数字+1,第2k个数字减一,k=0,1,2...n/2.  问最后能不能使n个数字刚好为排列为0,1,2,....n-1. 题解:简单模拟就好了,循环次数设为n-1,因为n次循环后回到原来的排列. #include <cstdio> #include <cmath> #include <cstring> #include &…
http://codeforces.com/problemset/problem/556/A 题意:给一个01字符串,把所有相邻的0和1去掉,问还剩下几个0和1. 题解:统计所有的0有多少个,1有多少个,最后答案就是两者不同的个数. #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algo…
Problem A: 题目大意:给你一个由0,1组成的字符串,如果有相邻的0和1要消去,问你最后还剩几个字符. 写的时候不想看题意直接看样例,结果我以为是1在前0在后才行,交上去错了..后来仔细 看了看,哎.以后不能自以为是啊. #include<bits/stdc++.h> using namespace std; *1e5+; char s[N]; bool vis[N]; int main() { int n; scanf("%d%s",&n,s); int…
https://github.com/Anoxxx/OI/blob/master/Anoxx/Contest10 github自取…
A:原来是大水题,我还想去优化.. 结果是abs(num('0')-num('1')); num表示一个符号的个数; B:暴力模拟即可,每次判断是否能构造出答案. C:俄罗斯套娃,套套套,捉鸡的E文. 抛开乱七八糟的题意: 思路就是除了1连续的不拆开,其他都拆,所以乱写就好了. #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include &l…
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is…
当时晚上打CF时候比较晚,加上是集训期间的室友都没有晚上刷题的习惯,感觉这场CF很不在状态.A题写复杂WA了一发后去厕所洗了个脸冷静了下,换个简单写法,可是用cin加了ios::sync_with_stdio(false)还是WA了,真无语.B题读半天题,读懂后轻松A了,看了下比赛时间就快结束了,把C题读了一遍后,感觉能做,最后还是选择了睡觉23333.................. A题大意:平平平 增平减 ,缺任一都可,判断是否为这样的数列 #include<stdio.h> #inc…
传送门 题意: 给出一个数x,有两个操作: ①:x ^= 2k-1; ②:x++; 每次操作都是从①开始,紧接着是② ①②操作循环进行,问经过多少步操作后,x可以变为2p-1的格式? 最多操作40次,输出操作数和所有操作中步骤①的操作数的k: 我的思路: 操作①每次都是异或 (k-1) 个1: 我们最终的结果是将 x 变为(p-1)个1: 那么,我们只要每次异或操作都将x中最高的0位变为1: 因为x最多只有20位,所以,完全可以在40个操作内将x变为(p-1)个1: 例如: 7654321(位置…
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 …