847C - Sum of Nestings

思路:简单的递归。

代码:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pb push_back
  5. #define mem(a,b) memset(a,b,sizeof(a))
  6.  
  7. void c(ll n,ll k)
  8. {
  9. ios::sync_with_stdio(false);
  10. cin.tie();
  11. if(n==)return ;
  12. if(k>=n-)
  13. {
  14. cout<<'(';
  15. c(n-,k-(n-));
  16. cout<<')';
  17. }
  18. else
  19. {
  20. cout<<"()";
  21. c(n-,k);
  22. }
  23. }
  24.  
  25. int main()
  26. {
  27. ios::sync_with_stdio(false);
  28. cin.tie();
  29. ll n,k;
  30. cin>>n>>k;
  31. if(n*(n-)/<k)cout<<"Impossible";
  32. else c(n,k);
  33. cout<<endl;
  34. return ;
  35. }

Codeforces 847C - Sum of Nestings的更多相关文章

  1. Codeforces 85D Sum of Medians(线段树)

    题目链接:Codeforces 85D - Sum of Medians 题目大意:N个操作,add x:向集合中加入x:del x:删除集合中的x:sum:将集合排序后,将集合中全部下标i % 5 ...

  2. Codeforces 1442D - Sum(找性质+分治+背包)

    Codeforces 题面传送门 & 洛谷题面传送门 智商掉线/ll 本来以为是个奇怪的反悔贪心,然后便一直往反悔贪心的方向想就没想出来,看了题解才发现是个 nb 结论题. Conclusio ...

  3. Codeforces 1303G - Sum of Prefix Sums(李超线段树+点分治)

    Codeforces 题面传送门 & 洛谷题面传送门 个人感觉这题称不上毒瘤. 首先看到选一条路径之类的字眼可以轻松想到点分治,也就是我们每次取原树的重心 \(r\) 并将路径分为经过重心和不 ...

  4. codeforces 616E Sum of Remainders (数论,找规律)

    E. Sum of Remainders time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  5. Codeforces 85D Sum of Medians

    传送门 D. Sum of Medians time limit per test 3 seconds memory limit per test 256 megabytes input standa ...

  6. Codeforces 616E - Sum of Remainders

    616E Sum of Remainders Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + - + n mod m. As ...

  7. 数据结构(线段树):CodeForces 85D Sum of Medians

    D. Sum of Medians time limit per test 3 seconds memory limit per test 256 megabytes input standard i ...

  8. Codeforces 920F - SUM and REPLACE 【线段树】

    <题目链接> 题目大意: 给你一个序列,有两个操作,一个是求区间 l - r 的和,另一个是对区间l-r的元素修改值,x=d(x),d(x)为x的因子个数. 解题分析: 因为可能有多次修改 ...

  9. Codeforces 920F - SUM and REPLACE

    920F - SUM and REPLACE 思路1: 线段树(982 ms) 每个点最多更新6次 代码: #include<bits/stdc++.h> using namespace ...

随机推荐

  1. DW课堂练习 用所学的知识去制作一个 (邮箱的注册页面)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. 论文参考文献中J、M等是什么意思

    最近不务正业的写论文,记录下常见的文献标示 国家期刊出版格式要求在中图分类号的下面应标出文献标识码,规定如下: 作者可从下列A.B.C.D.E中选用一种标识码来揭示文章的性质: A—理论与应用研究学术 ...

  3. ubuntu常用指令

    总结一下常用的linux指令. mark一个linux指令学习和速查的网站:http://man.linuxde.net/ (0) su和sudo:得到root权限 su 切换到root用户 sudo ...

  4. Python: 反方向迭代一个序列

    使用内置的reversed()函数 >>> a = [1, 2, 3, 4] >>> for x in reversed(a): ... print(x) out ...

  5. Spring,Struts2,MyBatis,Activiti,Maven,H2,Tomcat集成(四)——Activiti集成

    1.添加Activiti Maven依赖: <!-- ==============================activiti=========================== --&g ...

  6. python3.4学习笔记(二) 类型判断,异常处理,终止程序

    python3.4学习笔记(二) 类型判断,异常处理,终止程序,实例代码: #idle中按F5可以运行代码 #引入外部模块 import xxx #random模块,randint(开始数,结束数) ...

  7. python之路----进程三

    IPC--PIPE管道 #创建管道的类: Pipe([duplex]):在进程之间创建一条管道,并返回元组(conn1,conn2),其中conn1,conn2表示管道两端的连接对象,强调一点:必须在 ...

  8. pyDay1

    1.import python中的import语句是用来导入模块的. 在python的模块库中有大量的模块可供使用,要想使用这些文件需要用import语句把指定模块导入到当前程序中, 使用方法例如: ...

  9. html判断当前页面是否在iframe中/顶级document中

    在使用div+iframe布局的应用中,通常我们希望在session超时或者未登录访问时跳转到登录页面,默认情况下iframe中的页面无法直接覆盖父页面,因此需要在登录页面加载的时候判断一下当前是否为 ...

  10. 探索Java8:Stream的使用

    Java 8 API添加了一个新的抽象称为流Stream,可以让你以一种声明的方式处理数据. Stream 使用一种类似用 SQL 语句从数据库查询数据的直观方式来提供一种对 Java 集合运算和表达 ...