A

  1. /* Huyyt */
  2. #include <bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define mkp(a,b) make_pair(a,b)
  5. #define pb push_back
  6. const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
  7. using namespace std;
  8. typedef long long ll;
  9. inline void read(int &v)
  10. {
  11. v = ;
  12. char c = ;
  13. int p = ;
  14. while (c < '' || c > '')
  15. {
  16. if (c == '-')
  17. {
  18. p = -;
  19. }
  20. c = getchar();
  21. }
  22. while (c >= '' && c <= '')
  23. {
  24. v = (v << ) + (v << ) + c - '';
  25. c = getchar();
  26. }
  27. v *= p;
  28. }
  29. const long long mod = 1e9 + ;
  30. const int N = 1e5 + ;
  31. int main()
  32. {
  33. ll a, b, c, k;
  34. cin >> a >> b >> c >> k;
  35. if (k % == )
  36. {
  37. cout << b - a << endl;
  38. }
  39. else
  40. {
  41. cout << a - b << endl;
  42. }
  43. return ;
  44. }

B

只要算出最长 数字连续子序列就可以了

  1. /* Huyyt */
  2. #include <bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define mkp(a,b) make_pair(a,b)
  5. #define pb push_back
  6. const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
  7. using namespace std;
  8. typedef long long ll;
  9. inline void read(int &v)
  10. {
  11. v = ;
  12. char c = ;
  13. int p = ;
  14. while (c < '' || c > '')
  15. {
  16. if (c == '-')
  17. {
  18. p = -;
  19. }
  20. c = getchar();
  21. }
  22. while (c >= '' && c <= '')
  23. {
  24. v = (v << ) + (v << ) + c - '';
  25. c = getchar();
  26. }
  27. v *= p;
  28. }
  29. const long long mod = 1e9 + ;
  30. const int N = 2e5 + ;
  31. int n;
  32. int num[N];
  33. int aim[N];
  34. int main()
  35. {
  36. read(n);
  37. int now;
  38. for (int i = ; i <= n; i++)
  39. {
  40. read(now);
  41. num[now] = i;
  42. }
  43. int ans = ;
  44. int ansmaxn = ;
  45. for (int i = ; i <= n; i++)
  46. {
  47. if (num[i] > num[i - ])
  48. {
  49. ans++;
  50. }
  51. else
  52. {
  53. ans = ;
  54. }
  55. ansmaxn = max(ansmaxn, ans);
  56. }
  57. cout << n - ansmaxn << endl;
  58. return ;
  59. }

C

给你两个数组A,B  A全为0  B是给定的N个数

一次操作可以使得Ai(2<=i<=N) 变为 Ai-1+1

解:

首先排除不合法的情况: ①.当A0不为0的时候 ②.当前面的数减后面的数大于1的时候

  1. /* Huyyt */
  2. #include <bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define mkp(a,b) make_pair(a,b)
  5. #define pb push_back
  6. const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
  7. using namespace std;
  8. typedef long long ll;
  9. inline void read(int &v)
  10. {
  11. v = ;
  12. char c = ;
  13. int p = ;
  14. while (c < '' || c > '')
  15. {
  16. if (c == '-')
  17. {
  18. p = -;
  19. }
  20. c = getchar();
  21. }
  22. while (c >= '' && c <= '')
  23. {
  24. v = (v << ) + (v << ) + c - '';
  25. c = getchar();
  26. }
  27. v *= p;
  28. }
  29. const long long mod = 1e9 + ;
  30. const int N = 2e5 + ;
  31. int n;
  32. ll num[N];
  33. int main()
  34. {
  35. read(n);
  36. for (int i = ; i <= n; i++)
  37. {
  38. cin >> num[i];
  39. }
  40. if (num[] != )
  41. {
  42. cout << - << endl;
  43. return ;
  44. }
  45. for (int i = ; i <= n; i++)
  46. {
  47. if (num[i] - num[i - ] > )
  48. {
  49. cout << - << endl;
  50. return ;
  51. }
  52. }
  53. ll anser = ;
  54. for (int i = ; i <= n; i++)
  55. {
  56. if (num[i] == num[i - ] + )
  57. {
  58. anser++;
  59. }
  60. else
  61. {
  62. anser += num[i];
  63. }
  64. }
  65. cout << anser << endl;
  66. return ;
  67. }

D

At grand 024的更多相关文章

  1. Atcoder Grand Contest 024 E - Sequence Growing Hard(dp+思维)

    题目传送门 典型的 Atcoder 风格的计数 dp. 题目可以转化为每次在序列中插入一个 \([1,k]\) 的数,共操作 \(n\) 次,满足后一个序列的字典序严格大于前一个序列,问有多少种操作序 ...

  2. Atcoder Grand Contest 024

    A 略 B 略 C 略 D(构造分形) 题意: 给出一个由n个点的组成的树,你可以加一些点形成一个更大的树.对于新树中的两个点i和j,如果以i为根的树与以j为根的树是同构的那么i和j颜色可以相同.问最 ...

  3. [AtCoder Grand Contest 024 Problem E]Sequence Growing Hard

    题目大意:考虑 N +1 个数组 {A0,A1,…,AN}.其中 Ai 的长度是 i,Ai 内的所有数字都在 1 到 K 之间. Ai−1 是 Ai 的子序列,即 Ai 删一个数字可以得到 Ai−1. ...

  4. NSThread 子线程 Cocoa NSOperation GCD(Grand Central Dispatch) 多线程

    单词:thread 英 θred:n 线.思路.vt 穿过.vi 穿透过 一.    进程.线程 进程:正在进行中的程序被称为进程,负责程序运行的内存分配,每一个进程都有自己独立的虚拟内存空间 线程: ...

  5. Reading With Purpose: A grand experiment

    Reading With Purpose: A grand experiment This is the preface to a set of notes I'm writing for a sem ...

  6. 在Swift中应用Grand Central Dispatch(上)转载自的goldenfiredo001的博客

    尽管Grand Central Dispatch(GCD)已经存在一段时间了,但并非每个人都知道怎么使用它.这是情有可原的,因为并发很棘手,而且GCD本身基于C的API在 Swift世界中很刺眼. 在 ...

  7. Grand Central Dispatch (GCD)

    Grand Central Dispatch (GCD) Reference Grand Central Dispatch (GCD) comprises language features, run ...

  8. iOS 中NSOperationQueue,Grand Central Dispatch , Thread的上下关系和区别

    In OS X v10.6 and later, operation queues use the libdispatch library (also known as Grand Central D ...

  9. php大力力 [024节]PHP中的字符串连接操作(2015-08-27)

    2015-08-27 php大力力024.PHP中的字符串连接操作 PHP中的字符串连接操作  阅读:次   时间:2012-03-25 PHP字符串的连接的简单实例 时间:2013-12-30 很多 ...

随机推荐

  1. leetcode 297二叉树的序列化与反序列化

    to_string(x) 将数字x转化为string atoi(x) 将char转化为int stoi(x) 将string 转化为int 采用中序遍历的顺序存储,NULL用#表示,以,分隔,O(n) ...

  2. web开发(四) 一次性验证码的代码实现

    在网上看见一篇不错的文章,写的详细. 以下内容引用那篇博文.转载于<http://www.cnblogs.com/whgk/p/6426072.html>,在此仅供学习参考之用. 其实实现 ...

  3. 函数对象的apply()和call()方法

    每个函数都包含两个非继承而来的方法:apply()和call().这两个方法的用途都是在特定的作用域中调用函数,特定的作用域为this参数指定的对象. apply()和call()真正强大的地方是能够 ...

  4. Dojo入门:DOM操作

      作为一款功能齐全的js工具包,dojo提供了统一的DOM操作方法. dojo.byId dojo.byId 函数使您可以通过 id 属性选择一个 DOM 节点.该函数是标准 document.ge ...

  5. Linux man及echo的使用

    学习目标: 通过本实验掌握man和echo两个命令的用法. 实验步骤: 1.通过man查询ls的详细用法,后面可以跟哪些参数,每个参数的作用.这里主要查找如何禁止ls彩色结果输出. 2.把查找到的参数 ...

  6. C++ 多文件编译简述:头文件、链接性、声明与定义

    目录 Commen Sense 头文件 链接性 static 与链接性控制 extern 与外部链接性 Reference Commen Sense C++ 在编译时对每个翻译单元(Translati ...

  7. 【神经网络与深度学习】【VS开发】【CUDA开发】VS2013 配置CUDNN V4 DEMO

    VS2013 配置CUDNN V4 DEMO 众所周知,当前主流深度学习的实现中调用的底层API都是cudnn,自己做项目需要开发深度学习模块时,也需要调用cudnn库,因此熟悉cudnn库是很有必要 ...

  8. 20191209 Linux就该这么学(4)

    4. Vim编辑器与Shell命令脚本 Vim 编辑器中设置了三种模式-命令模式.末行模式和编辑模式. 命令模式:控制光标移动,可对文本进行复制.粘贴.删除和查找等工作. 输入模式:正常的文本录入. ...

  9. AndroidStudio ADB WIFI :adb wifi scan ip address

    笔记本使用Android studio的adb wifi插件时,AS 最下方报 adb wifi scan ip address.一直无法使用. 解决办法: ----在Terminal窗口中输入: a ...

  10. python的并发GIL 了解

    gil  又称 global interpreter lock (全局解释器锁) #python 中一个线程对应于c语言中的一个线程 #gil使得同一个时刻只有一个线程在一个cpu上执行字节码,无法将 ...