贪心——Kickstart 2017 practice Round #C
来源:互联网 发布:人民法院淘宝网 编辑:程序博客网 时间:2024/04/27 04:43
题目链接: https://codejam.withgoogle.com/codejam/contest/6304486/dashboard#s=p2
题意: 给你L和M,表示一个长度为L+M的串里包含L个’(‘,和M个’)’,求这个串的所有子串中,包含合法串的最大数量是多少?
合法子串:
It is the empty string, or:It has the form (S), where S is a balanced string, or:It has the form S1S2, where S1 is a balanced string and S2 is a balanced string.
分析: 当所以合法子串连在一块时,它们能组成的合法串最多,即 ()()()()()()()))))))) 或者 ()()()()()()()()()()(((((((( 这种,然后它们的包含的合法子串数量就是 n + (n-1) + (n-2) + (n-3) + .. + 1
AC代码:
//也就一个公式LL a = min(L,R);cout << a*(1+a)/2 << endl;
0 0
- 贪心——Kickstart 2017 practice Round #C
- 数学——Kickstart 2017 practice Round #B
- Kickstart Practice Round 2017 Problem C. Sherlock and Parentheses
- Kickstart Practice Round 2017 Problem B. Vote
- Kickstart Practice Round 2017 Problem A. Country Leader
- Kickstart Practice Round 2 2017 Problem A. Diwali lightings
- Kickstart Round A 2017
- Kickstart 2017 Round A
- Kickstart Round A 2017 Problem C. Space Cubes
- Kickstart Round G 2017 Problem C. Matrix Cutting
- Practice Round APAC test 2017——Problem C. Not So Random
- 记忆化搜索(字符串)——Kickstart 2017(Google Code Jam) A Round #B
- Kickstart Round B 2017——Problem B. Center(及一点延伸)
- Google Kickstart 2017 Round A 题解
- Kickstart Round B 2017 Problem B. Center
- Practice Round APAC test 2017——1.Problem A. Lazy Spelling Bee
- Practice Round APAC test 2017——Problem B. Robot Rock Band
- Practice Round APAC test 2017——Problem D. Sums of Sums
- 《数学之美》第一章脑图:文字,数字与信息
- MyBatis快速入门(三) 动态SQL
- android打包提示checkreleasebuilds false
- 401. Binary Watch -Easy
- linux关于S权限和T权限的介绍
- 贪心——Kickstart 2017 practice Round #C
- JAVA全集-07-Java集合
- 【backtrack】路由信息收集
- 51 NOD 1012 最小公倍数LCM
- C++ 字符串分割 split
- asp.net core mvc剖析:处理管道构建
- 脱离文档流之 float 和 position:absolute的区别
- 详解如何将TensorFlow训练的模型移植到Android手机
- 浅谈Java中的泛型