题意:有一个小朋友,即喜欢下象棋,还喜欢编程,于是他打算上这两种课的兴趣班,这两种课有着不同的上课时间,他想让两堂课之间的休息时间最多,问最大时间是多少 思路:看到这道题的第一反应就是贪心,于是用结构体排个序然后再暴力枚举....果断超时了,其实只要找两个区间差最远的就可以了 代码: #include <bits/stdc++.h> #define inf 1e9 using namespace std; int main() { int l1,r1,l2,r2; l1=;r1=inf; l2…
B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has n variants when he wil…
题意:给你一个由'('和')'组成的字符串,问你有多少个子串,前半部分是由'('组成后半部分由')'组成 思路:枚举这个字符串中的所有'('左括号,它左边的所有'('左括号的个数为num1,它的右边的所有')'右括号的个数为num2, 根据范德蒙恒等式计算得出 代码: #include <bits/stdc++.h> #define ll long long #define maxn 200000 #define mod 1000000007 using namespace std; ll j…
D. Anton and School - 2 题目连接: http://codeforces.com/contest/785/problem/D Description As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn differ…
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there liv…
A - Anton and Polyhedrons 题目连接: http://codeforces.com/contest/785/problem/A Description Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular face…
E. Anton and Permutation time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a…
题目链接 转自 给你一个字符串问你能构造多少RSBS. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; LL gcd(LL a,LL b){return b?gcd(b,a%b):a;} LL lcm(LL a,LL b){return a/gcd(a,b)*…
http://codeforces.com/blog/entry/50996 官方题解讲得很明白,在这里我复述一下. 枚举每个左括号,考虑计算一定包含其的简单括号序列的个数,只考虑其及其左侧的左括号,以及其右侧的右括号.最后答案就是其之和. 可以将其提取出来这样((((((())),红色为当前左括号.设有x个左,y个右 要注意,这个答案为C(x+y-1,x),来证明. 我们只需证明,这个答案与长度为x+y-1的,包含x个1的零一序列的种类数相等即可. 随便写一个这样的零一序列,长度为x+y,但当…
当m>=n时,显然答案是n: 若m<n,在第m天之后,每天粮仓减少的量会形成等差数列,只需要二分到底在第几天,粮仓第一次下降到0即可. 若直接解不等式,可能会有误差,需要在答案旁边扫一下. 注意二分上界的确定,不能太小也不能太大. #include<cstdio> #include<iostream> using namespace std; typedef long long ll; ll n,m; int main(){ cin>>n>>m;…