C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n.…
A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks. Each minute can be either interesting or…
B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pic…
E. Bear and Contribution 题目连接: http://www.codeforces.com/contest/658/problem/E Description Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution - an integer…
D. Bear and Two Paths 题目连接: http://www.codeforces.com/contest/673/problem/D Description Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same p…
题目链接: http://codeforces.com/contest/673/problem/D 题意: 给四个不同点a,b,c,d,求是否能构造出两条哈密顿通路,一条a到b,一条c到d. 题解: 构造法,看例子: input: 5 6 5 2 4 1 output: 5 4 3 1 2 4 5 3 2 1 所以只要满足k>=n+1,就可以构造出来答案. #include<iostream> #include<cstring> #include<cstdio>…
题目链接: http://codeforces.com/contest/673/problem/C 题解: 枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了. 暴力n*n. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; ; const int…
连接在这里,->点击<- 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 ther…
C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should s…
B. Problems for Round 题目连接: http://www.codeforces.com/contest/673/problem/B Description There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficult…
D. Bear and Polynomials 题目连接: http://www.codeforces.com/contest/658/problem/D Description Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials. He considers a polynomial valid if its degree is n and its coe…
C. Bear and Forgotten Tree 3 题目连接: http://www.codeforces.com/contest/658/problem/C Description A tree is a connected undirected graph consisting of n vertices and n  -  1 edges. Vertices are numbered 1 through n. Limak is a little polar bear and Rade…
B. Bear and Displayed Friends 题目连接: http://www.codeforces.com/contest/658/problem/B Description Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is describ…
A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in…
B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty,…
C. Bear and Forgotten Tree 3 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A tree is a connected undirected graph consisting of n vertices and n  -  1 edges. Vertices are numbered 1 thro…
题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2.1,2位置交换,3,4位置交换,...,n-1,n位置交换 现在问执行了q次操作之后序列是什么,每次操作可以是两种操作的任意一种 题解: 我们把数列按位置的奇偶分为两堆,无论哪种操作,始终都还是这两堆,最多就是整堆的对换和一个堆内部的偏移. 所以我们只要记录第一个位置和第二个位置的数的变化(相当于每…
C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Description Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Cons…
E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply thi…
D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cuban dance that is danced by pairs of boys and girls forming a circle and dancing tog…
C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new contro…
B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1 × n. Each ce…
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the prese…
我们要统计的答案是sigma([L/K]),L为路径的长度,中括号表示上取整. [L/K]化简一下就是(L+f(L,K))/K,f(L,K)表示长度为L的路径要想达到K的整数倍,还要加上多少. 于是,我们现在只需要统计sigma((L+f(L,K))),最后除以K即可. 统计sigma(L)时,我们考虑计算每条边出现在了几条路径中,设u为edgei的子节点,那么这条边对答案的贡献就是siz(u)*(n-siz(u)),siz(u)为u的子树大小. 统计sigma(f(L,K))时,我们需要dp出…
D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two dist…
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n…
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…
A. Bear and Reverse Radewoosh time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equa…
A - Little Artem and Presents (div2) 1 2 1 2这样加就可以了 #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int main() { int n; scanf ("%d", &n); int ans = n / 3 * 2; if (n % 3) { ans++; } printf ("%d\n", ans);…
A.暴力枚举,注意游戏最长为90分钟 B.暴力,c[l]++,c[r]--,记录中间有多长的段是大小为n的,注意特判m=0的情况 C.暴力枚举,我居然一开始没想出来!我一直以为每次都要统计最大的,就要O(N^3).实际上只要判断最大的那个. D.构造,在除了a,b,c,d之外的点构造一条链,只需要n+1条边就可以了.n=4的时候特判.…