(2016弱校联盟十一专场10.3) D Parentheses
把左括号看成A右括号看成B,推一下就行了。好久之前写的,推到最后发现是一个有规律的序列。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;
while(scanf("%lld",&n)!=EOF)
{
ll cnt=,sum=;
for(int i=;; i++)
{
if(sum>=n) break;
cnt++;
sum=sum+cnt;
//printf("%d : %d\n",i,sum);
}
printf(")");
ll a=sum-n;
ll b=cnt-a;
for(int i=;i<=cnt;i++)
{
if(b==i)
printf("(");
else
printf(")");
}
for(int i=;i<cnt-;i++)
printf("(");
puts("");
}
return ;
}
(2016弱校联盟十一专场10.3) D Parentheses的更多相关文章
- 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, t ...
- 2016弱校联盟十一专场10.3---Similarity of Subtrees(深搜+hash、映射)
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a ...
- (2016弱校联盟十一专场10.3) B.Help the Princess!
题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<qu ...
- (2016弱校联盟十一专场10.3) A.Best Matched Pair
题目链接 #include<cstdio> #include<cstring> #include<algorithm> #include<stack> ...
- 2016弱校联盟十一专场10.3---We don't wanna work!(STL--set的使用)
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C 代码如下: #include <iostream> # ...
- 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem description In ICPCCamp, there ar ...
- (2016弱校联盟十一专场10.2) A.Nearest Neighbor Search
题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[], ...
- (2016弱校联盟十一专场10.2) E.Coins
题目链接 很久之前写的了,好像是对拍打表过的,推一下就行了. #include <bits/stdc++.h> using namespace std; typedef long long ...
- (2016弱校联盟十一专场10.5) F. Fibonacci of Fibonacci
题目链接 题目大意就是这个,先找出下标的循环节,再快速幂对20160519取余就行了. 找出下标循环节: #include <cstdio> #include <iostream&g ...
随机推荐
- git远程仓库
git远程仓库: 目前我们使用到的 Git 命令都是在本地执行,如果你想通过 Git 分享你的代码或者与其他开发人员合作. 你就需要将数据放到一台其他开发人员能够连接的服务器上. 添加远程仓库: gi ...
- SQL Linq lamda区别
SQL LINQ Lambda SELECT * FROM HumanResources.Employee from e in Employees select e Employees .Sele ...
- c# 集合
集合适用于元素个数是动态的情况. 当使用默认的构造函数创建一个空列表后(未指定容量),集合的容量为0:当往集合内添加元素,容量将变为4*2^n(n为0或正整数).当指定集合的大小为size后,容量将变 ...
- Python删除指定时间的文件
import os import time import sys from xml.dom import minidom, Node from xml.dom.minidom import parse ...
- 【BZOJ-2668】交换棋子 最小费用最大流
2668: [cqoi2012]交换棋子 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 1055 Solved: 388[Submit][Status ...
- opencv 比较直方图方式 进行人脸检测对比
完整opencv(emgucv)人脸.检测.采集.识别.匹配.对比 //成对几何直方图匹配 public static string MatchHist() ...
- AI贪吃蛇(二)
前言 之前写过一篇关于贪吃蛇AI的博客,当时虽然取得了一些成果,但是也存在许多问题,所以最近又花了三天时间重新思考了一下.以下是之前博客存在的一些问题: 策略不对,只要存在找不到尾巴的情况就可能失败, ...
- maven install时报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
首先检查父项目,子项目的jdk版本是否一致,编码格式是否一致我的问题就错在了编码格式上,父项目用的是UTF-8,子项目新建的,默认GBK这时,使用maven install命令出错 提示:[INFO] ...
- jQuery知识点一 each()和toggleClass()
jQuery的一些东东比较容易忘,所以在这里整理一下... ... 1. each (1) $(selector).each(function(index,element)) inde ...
- 前端项目构建工具---Grunt
什么是Grunt? grunt是javascript项目构建工具,在grunt流行之前,前端项目的构建打包大多数使用ant.(ant具体使用 可以google),但ant对于前端而言,存在不友好,执行 ...