/* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[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. 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…
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…
/* 题意就是要找到包含“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));…
/* 贪心的找到相邻两项差的最大值,再减去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(…
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少步,按照这个次数之后的能否满足要求 题目读的好累:( */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath>…
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…