Codeforces Round #752 (Div. 2) A B C
A. Era
每个a[i] - i 表示的是当前a[i]前需要插入几个数, 取所有a[i] - i 最大值即可.
#include <iostream>
#include <algorithm> using namespace std; typedef long long LL; int main(){
int t;
cin >> t; while(t--)
{
int n, x; cin >> n;
int res = 0;
for(int i = 1; i <= n; i ++)
{
cin >> x;
res = max(res, x-i);
}
cout << res <<endl; }
return 0;
}
B. XOR Specia-LIS-t
位运算思维
如果n是偶数的话,可以分成n个序列, 那么偶数个1异或之后必然为0。
那么如果n是奇数, 如果存在一组a[i] <= a[i-1], 将其归为一组, 则n-1个1异或后也必然为0
#include <iostream>
#include <algorithm> using namespace std; typedef long long LL; const int N = 1e5 + 10; int a[N]; int main(){
int t;
cin >> t; while(t--)
{
int n;
cin >> n;
for (int i = 1; i <= n; i ++ )
cin >> a[i]; if(n % 2 == 0)
{
cout << "YES" << endl;
continue;
} bool flag = false;
for (int i = 2; i <= n; i ++ )
if(a[i] <= a[i - 1]) //注意有=号
{
flag = true;
break;
} if(flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
C. Di-visible Confusion
我们可以选择从后往前看这个序列, 这样每删除一个数会尽量不影响其他的数字, 对于每次操作分两种情况:
1. 可以删去a[i]%(i+1) != 0, 没有操作
2. 否则, 如果取余2~i 都为0, 那么这个数算是删不了了, 注定结果失败
只要不失败就成功.
#include <iostream>
#include <algorithm> using namespace std; typedef long long LL; const int N = 1e5 + 10; int a[N]; int main(){
int t;
cin >> t; while(t--)
{
int n; cin >> n; bool res_ok = 1; for(int i = 1; i <= n; i ++) cin >> a[i]; for(int i = n; i >= 1; -- i)
{
if(a[i]%(i+1) == 0)
{
int flag = 0;
for(int j = i; j > 1; -- j)
if(a[i] % j != 0)
{
flag = 1;
break;
} if(!flag)
res_ok = 0;
}
}
if(!res_ok)
puts("NO");
else
puts("YES");
}
return 0;
}
Codeforces Round #752 (Div. 2) A B C的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- table元素使用bug
一.问题的产生 javaWeb课上老师让我们用表单做一个简单的自我介绍,但是在对表单里的单元格进行合并时出现了变形的情况,这里做个记录. 二.实验 让我们先做一个简单的4*4表格 <!DOCTY ...
- 实现一个cache
实现一个LRU cache,定义get函数和set函数,cache是固定长度的,当cache已经满,那么就删除一直没有被更新的记录,然后将新的记录放进去. LRU: 全称是Least Recently ...
- Python_Learn,Python背景的介绍
一.计算机程序的运行方式 机器语言编写的程序可以在计算机上直接运行,而汇编语言和高级余语言写的程序(通常称为源程序)则需要"翻译"成机器语言才能运行.源程序"翻译&quo ...
- Mybatis 是如何进行分页的?分页插件的原理是什么?
Mybatis 使用 RowBounds 对象进行分页,它是针对 ResultSet 结果集执行的内 存分页,而非物理分页.可以在 sql 内直接书写带有物理分页的参数来完成物理分 页功能,也可以使用 ...
- Anonymous Inner Class(匿名内部类)是否可以继承其它类?是否可以实现接口?
可以继承其他类或实现其他接口,在 Swing 编程和 Android 开发中常用此方式来 实现事件监听和回调.
- 接口是否可继承(extends)接口?抽象类是否可实现 (implements)接口?抽象类是否可继承具体类(concrete class)?
接口可以继承接口,而且支持多重继承.抽象类可以实现(implements)接口,抽象类可继承具体类也可以继承抽象类.
- BeanFactory – BeanFactory 实现举例?
Bean 工厂是工厂模式的一个实现,提供了控制反转功能,用来把应用的配置和依赖从正真的应用代码中分离. 最常用的BeanFactory 实现是XmlBeanFactory 类.
- spring-boot-learning-MongoDB
NoSQL可以极大提高互联网系统的性能,但是它有一些致命的缺陷,其中最为严重的就是计算功能卡分有限,例如,在一个10 万数据量的List 中,我只需要满足特定条件的元素在Red is 中,使用集合或者 ...
- SQLAlchemy 使用教程
前戏: 不用怀疑,你肯定用过Django中的orm,这个orm框架是django框架中自己封装的,在Django中配置和使用较为简单,但是并不适用于其他web框架,而今天说的sqlalchemy是 ...
- 学习openstack(五)
OpenStackOpenStack介绍OpenStack是一种免费的开源平台,帮助服务提供商实现类似于亚马逊EC2和S3的基础设施服务.OpenStack当前有三个核心项目:计算(Nova),对象存 ...