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. Java案例——反转字符串

    /*案例:将用户输入的字符串反转并输出 分析:1.使用Scanner 类获取用户输入的字符串 2.定义一个方法将字符串反着遍历并拼接 3.定义变量接受并输出* */public class Strin ...

  2. DDOS防御实验----反射器的安全配置

    0x01 环境 共包含三台主机 一台centos7.3 为attact主机,装有python +Scapy 一台centos7.3,server,装有bind9 ntp memcached,作为DDO ...

  3. BUAA 2021-2022毛概复习资料

    2021-2022年毛概期末主观题复习范围,参考2022版教材和课程组官方PPT,原文太过敏感,所以贴出代码大家自己run #include <stdio.h> unsigned arti ...

  4. 一个lseek引起的思考

    先看一段代码: int find_value(int fd) { int ret; char buff[8] = ""; struct timeval st,ed; long lo ...

  5. iOS全埋点解决方案-应用退出和启动

    前言 ​ 通过应用程序退出事件,可以分析应用程序的平均使用时长:通过应用程序的启动事件,可以分析日活和新增.我们可以通过全埋点方式 SDK 实现应用程序的退出和启动事件. 一.全埋点的简介 ​ 目前. ...

  6. React算法复杂度优化?

    react树对比是按照层级去对比的, 他会给树编号0,1,2,3,4.... 然后相同的编号进行比较.所以复杂度是n,这个好理解. 关键是传统diff的复杂度是怎么算的?传统的diff需要出了上面的比 ...

  7. CSS3实现环形进度条?

    两个对半矩形遮罩, 使用rotate以及overflow: hidden进行旋转

  8. Shiro集成多个Realm,认证都不通过返回y configured realms. Please ensure that at least one realm can authenticate these tokens.

    异常内容:Authentication token of type [class org.apache.shiro.authc.UsernamePasswordToken] could not be ...

  9. docker打包镜像,测试部署

    docker基本入门以后,(docker基本入门https://www.cnblogs.com/yangyangming/p/11470926.html)可以试试打包docker镜像与dockerfi ...

  10. PRODUCER配置加载

    1.入口 Kafka通过new一个KafkaProducer将配置项进行加载.将用户定义的properties作为参数,构造成一个ProducerConfig对象. public KafkaProdu ...