At grand 024
A
- /* Huyyt */
- #include <bits/stdc++.h>
- #define mem(a,b) memset(a,b,sizeof(a))
- #define mkp(a,b) make_pair(a,b)
- #define pb push_back
- const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
- using namespace std;
- typedef long long ll;
- inline void read(int &v)
- {
- v = ;
- char c = ;
- int p = ;
- while (c < '' || c > '')
- {
- if (c == '-')
- {
- p = -;
- }
- c = getchar();
- }
- while (c >= '' && c <= '')
- {
- v = (v << ) + (v << ) + c - '';
- c = getchar();
- }
- v *= p;
- }
- const long long mod = 1e9 + ;
- const int N = 1e5 + ;
- int main()
- {
- ll a, b, c, k;
- cin >> a >> b >> c >> k;
- if (k % == )
- {
- cout << b - a << endl;
- }
- else
- {
- cout << a - b << endl;
- }
- return ;
- }
B
只要算出最长 数字连续子序列就可以了
- /* Huyyt */
- #include <bits/stdc++.h>
- #define mem(a,b) memset(a,b,sizeof(a))
- #define mkp(a,b) make_pair(a,b)
- #define pb push_back
- const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
- using namespace std;
- typedef long long ll;
- inline void read(int &v)
- {
- v = ;
- char c = ;
- int p = ;
- while (c < '' || c > '')
- {
- if (c == '-')
- {
- p = -;
- }
- c = getchar();
- }
- while (c >= '' && c <= '')
- {
- v = (v << ) + (v << ) + c - '';
- c = getchar();
- }
- v *= p;
- }
- const long long mod = 1e9 + ;
- const int N = 2e5 + ;
- int n;
- int num[N];
- int aim[N];
- int main()
- {
- read(n);
- int now;
- for (int i = ; i <= n; i++)
- {
- read(now);
- num[now] = i;
- }
- int ans = ;
- int ansmaxn = ;
- for (int i = ; i <= n; i++)
- {
- if (num[i] > num[i - ])
- {
- ans++;
- }
- else
- {
- ans = ;
- }
- ansmaxn = max(ansmaxn, ans);
- }
- cout << n - ansmaxn << endl;
- return ;
- }
C
给你两个数组A,B A全为0 B是给定的N个数
一次操作可以使得Ai(2<=i<=N) 变为 Ai-1+1
解:
首先排除不合法的情况: ①.当A0不为0的时候 ②.当前面的数减后面的数大于1的时候
- /* Huyyt */
- #include <bits/stdc++.h>
- #define mem(a,b) memset(a,b,sizeof(a))
- #define mkp(a,b) make_pair(a,b)
- #define pb push_back
- const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
- using namespace std;
- typedef long long ll;
- inline void read(int &v)
- {
- v = ;
- char c = ;
- int p = ;
- while (c < '' || c > '')
- {
- if (c == '-')
- {
- p = -;
- }
- c = getchar();
- }
- while (c >= '' && c <= '')
- {
- v = (v << ) + (v << ) + c - '';
- c = getchar();
- }
- v *= p;
- }
- const long long mod = 1e9 + ;
- const int N = 2e5 + ;
- int n;
- ll num[N];
- int main()
- {
- read(n);
- for (int i = ; i <= n; i++)
- {
- cin >> num[i];
- }
- if (num[] != )
- {
- cout << - << endl;
- return ;
- }
- for (int i = ; i <= n; i++)
- {
- if (num[i] - num[i - ] > )
- {
- cout << - << endl;
- return ;
- }
- }
- ll anser = ;
- for (int i = ; i <= n; i++)
- {
- if (num[i] == num[i - ] + )
- {
- anser++;
- }
- else
- {
- anser += num[i];
- }
- }
- cout << anser << endl;
- return ;
- }
D
At grand 024的更多相关文章
- Atcoder Grand Contest 024 E - Sequence Growing Hard(dp+思维)
题目传送门 典型的 Atcoder 风格的计数 dp. 题目可以转化为每次在序列中插入一个 \([1,k]\) 的数,共操作 \(n\) 次,满足后一个序列的字典序严格大于前一个序列,问有多少种操作序 ...
- Atcoder Grand Contest 024
A 略 B 略 C 略 D(构造分形) 题意: 给出一个由n个点的组成的树,你可以加一些点形成一个更大的树.对于新树中的两个点i和j,如果以i为根的树与以j为根的树是同构的那么i和j颜色可以相同.问最 ...
- [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. ...
- NSThread 子线程 Cocoa NSOperation GCD(Grand Central Dispatch) 多线程
单词:thread 英 θred:n 线.思路.vt 穿过.vi 穿透过 一. 进程.线程 进程:正在进行中的程序被称为进程,负责程序运行的内存分配,每一个进程都有自己独立的虚拟内存空间 线程: ...
- 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 ...
- 在Swift中应用Grand Central Dispatch(上)转载自的goldenfiredo001的博客
尽管Grand Central Dispatch(GCD)已经存在一段时间了,但并非每个人都知道怎么使用它.这是情有可原的,因为并发很棘手,而且GCD本身基于C的API在 Swift世界中很刺眼. 在 ...
- Grand Central Dispatch (GCD)
Grand Central Dispatch (GCD) Reference Grand Central Dispatch (GCD) comprises language features, run ...
- 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 ...
- php大力力 [024节]PHP中的字符串连接操作(2015-08-27)
2015-08-27 php大力力024.PHP中的字符串连接操作 PHP中的字符串连接操作 阅读:次 时间:2012-03-25 PHP字符串的连接的简单实例 时间:2013-12-30 很多 ...
随机推荐
- leetcode 297二叉树的序列化与反序列化
to_string(x) 将数字x转化为string atoi(x) 将char转化为int stoi(x) 将string 转化为int 采用中序遍历的顺序存储,NULL用#表示,以,分隔,O(n) ...
- web开发(四) 一次性验证码的代码实现
在网上看见一篇不错的文章,写的详细. 以下内容引用那篇博文.转载于<http://www.cnblogs.com/whgk/p/6426072.html>,在此仅供学习参考之用. 其实实现 ...
- 函数对象的apply()和call()方法
每个函数都包含两个非继承而来的方法:apply()和call().这两个方法的用途都是在特定的作用域中调用函数,特定的作用域为this参数指定的对象. apply()和call()真正强大的地方是能够 ...
- Dojo入门:DOM操作
作为一款功能齐全的js工具包,dojo提供了统一的DOM操作方法. dojo.byId dojo.byId 函数使您可以通过 id 属性选择一个 DOM 节点.该函数是标准 document.ge ...
- Linux man及echo的使用
学习目标: 通过本实验掌握man和echo两个命令的用法. 实验步骤: 1.通过man查询ls的详细用法,后面可以跟哪些参数,每个参数的作用.这里主要查找如何禁止ls彩色结果输出. 2.把查找到的参数 ...
- C++ 多文件编译简述:头文件、链接性、声明与定义
目录 Commen Sense 头文件 链接性 static 与链接性控制 extern 与外部链接性 Reference Commen Sense C++ 在编译时对每个翻译单元(Translati ...
- 【神经网络与深度学习】【VS开发】【CUDA开发】VS2013 配置CUDNN V4 DEMO
VS2013 配置CUDNN V4 DEMO 众所周知,当前主流深度学习的实现中调用的底层API都是cudnn,自己做项目需要开发深度学习模块时,也需要调用cudnn库,因此熟悉cudnn库是很有必要 ...
- 20191209 Linux就该这么学(4)
4. Vim编辑器与Shell命令脚本 Vim 编辑器中设置了三种模式-命令模式.末行模式和编辑模式. 命令模式:控制光标移动,可对文本进行复制.粘贴.删除和查找等工作. 输入模式:正常的文本录入. ...
- AndroidStudio ADB WIFI :adb wifi scan ip address
笔记本使用Android studio的adb wifi插件时,AS 最下方报 adb wifi scan ip address.一直无法使用. 解决办法: ----在Terminal窗口中输入: a ...
- python的并发GIL 了解
gil 又称 global interpreter lock (全局解释器锁) #python 中一个线程对应于c语言中的一个线程 #gil使得同一个时刻只有一个线程在一个cpu上执行字节码,无法将 ...