Problem - A - Codeforces

Problem - B - Codeforces

Problem - C - Codeforces

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的更多相关文章

  1. 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 ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

随机推荐

  1. 海量数据分析更快、更稳、更准。GaussDB(for MySQL) HTAP只读分析特性详解

    本文作者康祥,华为云数据库内核开发工程师,研究生阶段主要从事SPARQL查询优化相关工作.目前在华为公司参与华为云GaussDB(for MySQL) HTAP只读内核功能设计和研发. 1. 引言 H ...

  2. java项目中日志的配置

    1.日志相关比较详细的介绍:https://www.cnblogs.com/tanshaoxiaoji/p/log4j_config.html 2.总结1中博客说的内容 目前市场上常用的日志有log4 ...

  3. java中对集合操作的易错点01

    今天用for循环遍历集合,对集合中满足条件的元素进行remove操作报错:ConcurrentModificationException 所以,在遍历集合进行增.删操作时,要使用迭代器的方式 publ ...

  4. python练习册 每天一个小程序 第0002题

    1 #-*-coding:utf-8-*- 2 __author__ = 'Deen' 3 ''' 4 题目描述: 5 将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型 ...

  5. tensorflow2.4与目标检测API在3060显卡上的配置安装

    目前,由于3060显卡驱动版本默认>11.0,因此,其不能使用tensorflow1版本的任何接口,所以学习在tf2版本下的目标检测驱动是很有必要的,此配置过程同样适用于任何30系显卡配置tf2 ...

  6. 怎么根据Comparable方法中的compareTo方法的返回值的正负 判断升序 还是 降序?

    public int compareTo(Student o) { return this.age - o.age; // 比较年龄(年龄的升序)    } 应该理解成return (-1)×(thi ...

  7. kafka producer 打数据,ack 为 0, 1, -1 的时候代表啥, 设置 -1 的时候,什么情况下,leader 会认为一条消息 commit了?

    1(默认)  数据发送到Kafka后,经过leader成功接收消息的的确认,就算是发送成功了.在这种情况下,如果leader宕机了,则会丢失数据. 0 生产者将数据发送出去就不管了,不去等待任何返回. ...

  8. windows服务器下frp实现内网穿透

    一.操作步骤 1.服务器:首先在服务器上解压到相应目录并配置frps.ini文件如下: 2.服务器:按下windows+R输入cmd进入命令窗口,进入到安装目录下运行frps.exe -c frps. ...

  9. 学习GlusterFS(五)

    一,分布式文件系统理论基础 1.1 分布式文件系统出现 计算机通过文件系统管理,存储数据,而现在数据信息爆炸的时代中人们可以获取的数据成指数倍的增长,单纯通过增加硬盘个数来扩展计算机文件系统的存储容量 ...

  10. 『忘了再学』Shell基础 — 6、Bash基本功能(输入输出重定向)

    目录 1.Bash的标准输入输出 2.输出重定向 (1)标准输出重定向 (2)标准错误输出重定向 (3)正确输出和错误输出同时保存 3.输入重定向 1.Bash的标准输入输出 我们前边一直在说,在Li ...