/* 题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复. */ 1 #include <stdio.h> #include <string.h> #include <stdlib.h> #define maxn 5005 char str[maxn]; int pos[maxn]; int main() { while(~scanf("%s",str)) { ; memset(pos, , sizeof(int));…
/* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h> #include <iostream> #include <string.h> #define maxn 10000010 using namespace std; int prime[maxn]; int isprime[maxn]; int x[maxn]; void m…
/* 贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include <stdio.h> #define maxn 105 int num[maxn]; int main() { int n,c; while(~scanf("%d%d",&n,&c)) { ; ;i < n;i++) scanf("%d",num+i); ;i < n-;i++){ ]; if(temp > ans) ans…
读懂题意发现是傻逼状压. 只要会向量旋转,以及直线求交点坐标就行了.(验证了我这俩板子都没毛病) 细节蛮多. #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; const double PI=acos(-1.0); #define EPS 0.00000001 struct Point { double x,y; Point(…
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f;…
B. Bear and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The bear has a string s = s1s2... s|s| (record |s| is the string's length), consisting of lowercase English letters. The…
C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. In the output section below you will see the information about flushing the output. Bea…
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance betwee…
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a posit…
D. Bear and Chase 题目连接: http://codeforces.com/contest/679/problem/D Description Bearland has n cities, numbered 1 through n. There are m bidirectional roads. The i-th road connects two distinct cities ai and bi. No two roads connect the same pair of…
E. Bear and Square Grid 题目连接: http://www.codeforces.com/contest/680/problem/E Description You have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). Two empty cells are directly connected if the…
D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many…
C. Bear and Prime 100 题目连接: http://www.codeforces.com/contest/680/problem/C Description This is an interactive problem. In the output section below you will see the information about flushing the output. Bear Limak thinks of some hidden number - an i…
B. Bear and Finding Criminals 题目连接: http://www.codeforces.com/contest/680/problem/B Description There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|. Limak…
A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer. Limak can discard (throw out) s…
这次精神状态不怎么好,第一题的描述看得我就蛋疼...看完就速度写了~~~最终fst了%>_<%,第二题写复杂了,一直WA pretest 3,然后就紧张,导致精神更不好了,一直纠结在第二题,时间就这样过了,再一次拿了0蛋,妈蛋,真是蒟蒻啊%>_<% A.看懂题之后就是A+B problem 代码: #include <iostream> #include <cstdio> #include <algorithm> #include <cst…
C. Bear and Square Grid time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). T…
A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no break…
不难发现在一次操作以后,hi=min(hi-1,hi-1,hi+1),迭代这个式子得到k次操作以后hi=min(hi-j-(k-j),hi-k,hi+j-(k-j)),j = 1,2,3... 当k == min(hi-j+j,hi+j+j)时hi会变成0,因为min具有传递性,那么可以左右分开来考虑,hi-j+j化一下就是hi-j-(i-j)+i,其中后面i和j无关,所以只要找出前面最小的hi-i 对于右边的类似处理,最后再扫一遍,得出最大的一个k就是答案. #include<bits/std…
算一下复杂度.发现可以直接暴.对于u枚举a和b,判断一下是否连边,更新答案. #include<bits/stdc++.h> using namespace std; int n,m; ; #define PB push_back vector<int> G[maxn]; bool g[maxn][maxn]; int deg[maxn]; const int INF = 0x3f3f3f3f; int main() { //freopen("in.txt",&…
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main() { int n; scanf("%d",&n); int t; scanf("%d",&t); ; i <= n; i++){ int v; scanf("%d",&v); q.push(v); } ; while(…
简单题,求一下所有数的2和3的幂是任意调整的,把2和3的因子除掉以后必须相等. 求lcm,爆了long long.我得好好反省一下,对连乘不敏感 #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ll a[maxn]; int main() { //freopen("in.txt","r",stdin); int n; scanf("%d",&am…
数论好题 题目要求:求给定序列的素因子如果在给定区间内该数字个数加1; 思路:打表时求出包含给素数因子的数的个数,详见代码 1 #include<cstring> +;      scanf(     memset(vis,,     memset(sum,,     ;i<n;i++)      {          scanf(         num[a]++;      }      ;i<MAX;i++)      {                   {       …
E. Wilbur and Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/E Description Wilbur the pig now wants to play with strings. He has found an n by m table consisting only of the digits from 0 to 9 where the…
http://codeforces.com/problemset/problem/150/B 题意: 给出n,m,k,n表示字符串的长度为n,m表示字符种类个数,k表示每k个数都必须是回文串,求满足要求的不同字符串有多少种. 思路:分奇偶推一下,当k为偶数时,容易发现如果n=k,那么有最多有k/2种不同的字符可填,如果n>k,你会发现此时所有位置都必须一样. 奇数的话会稍微麻烦一点,如果n=k,那么最多有k/2+1种不同的字符可填,如果n>k,你会发现此时最后只有2中不同的字符可填. #inc…
D - DZY Loves Strings 思路:感觉这种把询问按大小分成两类解决的问题都很不好想.. https://codeforces.com/blog/entry/12959 题解说得很清楚啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pai…
E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates that is defined…
题目链接:http://www.codeforces.com/problemset/problem/281/A题意:将一个英文字母的首字母变成大写,然后输出.C++代码: #include <cstdio> #include <cstring> ]; void solve(char *s) { if (*s >= 'a' && *s <= 'z') *s -= ; while (*s) { putchar(*s); s ++; } } int main(…
D. Alyona and Strings 题目连接: http://www.codeforces.com/contest/682/problem/D Description After returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona…
D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings, and he enjoys collecting them. In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh. Once DZ…