Codeforces Round #690 (Div. 3)

Codeforces Round #690 (Div. 3) D. Add to Neighbour and Remove 前缀和 outputstandard output Polycarp was given an array of a[1…n] of n integers. He can perform the following operation with the array a no more than n times: Polycarp selects the index i and adds the value ai to one of his choice of its neighbors. More formally 阅读详情

Codeforces Round #690 (Div. 3)

比赛的时候f想到思路,写了一半比赛就结束了,难受

A.Close Tuples

题意:

题解:

代码:

/*
6
7
3 4 5 2 9 1 1
4
9 2 7 1
11
8 4 3 1 2 7 8 7 9 4 2
1
42
2
11 7
8
1 1 1 1 1 1 1 1

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
int const N = 2e5 + 10;
int n, m, T, a[N];

int main() {
    cin >> T;
    while(T--) {
        cin >> n;
        for (int i =1 ; i <= n; ++i) cin >> a[i];
        int i = 1, j = n;
        while(i < j) {
            cout << a[i] << " " << a[j] << " ";
            i++, j--;
        }
        // cout << endl;
        if (i == j) cout << a[i] << endl;
        else cout << endl;
    }   
    return 0;
}

B.Close Tuples

题意:

题解:

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
int const N = 2e5 + 10;
int n, m, T;

int main() {
    cin >> T;
    while(T--) {
        cin >> n;
        string s;
        cin >> s;
        if (s == "2020") {
            puts("YES");
            continue;
        }
        int len = s.size();
        int flg = 0;
        for (int i = 0; i < len; ++i) {
            for (int j = i; j < len; ++j) {
                if (n - (j - i + 1) != 4) continue;
                string s1 = s.substr(0, i);
                string s2 = s.substr(j + 1);
                string s3 = s1 + s2;
                if (s3 == "2020") {
                    flg = 1;
                    break;
                }

            }
            if (flg) break;
        }
        if (flg) puts("YES");
        else puts("NO");
    }   
    return 0;
}

C.Close Tuples

题意:

题解:

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
int t, n;

int main() {
    LL res[50] = {1,        2,        3,         4,       5,       6,
                  7,        8,        9,         19,      29,      39,
                  49,       59,       69,        79,      89,      189,
                  289,      389,      489,       589,     689,     789,
                  1789,     2789,     3789,      4789,    5789,    6789,
                  16789,    26789,    36789,     46789,   56789,   156789,
                  256789,   356789,   456789,    1456789, 2456789, 3456789,
                  13456789, 23456789, 123456789, - 1,      - 1,      - 1,
                  - 1,       - 1};
    cin >> t;
    while (t--) {
        cin >> n;
        cout << res[n - 1] << endl;   
    }
    return 0;
}

D.Close Tuples

题意:

题解:

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int const N = 2e5 + 10;
int a[N];
LL sum[N];
vector<LL> v;
int n, t;

// 试除法求约数
vector<LL> get_divisors(LL x) {
    vector<LL> res;                                // 记录答案
    for (int i = 1; i <= x / i; ++i) {             // 枚举到sqrtx(x)
        if (x % i == 0) {                          // 如果能够整除
            res.push_back(i);                      // 放入i
            if (i != x / i) res.push_back(x / i);  // x/i不等于i,也放入答案中
        }
    }
    sort(res.begin(), res.end());  // 排序
    return res;
}

int main() {
    cin >> t;
    while (t--) {
        cin >> n;
        LL average = 0;
        for (int i = 1; i <= n; i++) 
            cin >> a[i], sum[i] = sum[i - 1] + a[i], average += a[i];
        
        v = get_divisors(average);
        LL ans = 1e9;
        for (int k = 0; k < v.size(); k++) {
            LL Sum = 0;
            int flg = 1;
            for (int i = 1; i <= n; i++) {
                Sum += a[i];
                if (Sum == v[k]) Sum = 0;
                
                if (Sum > v[k]) {
                    flg = 0;
                    break;
                }
            }
            if (flg) ans = min(ans, n-average/v[k]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}

E.Close Tuples

题意:

题解:

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

int const N = 2e5 + 10, mod = 1e9 + 7;
int fact[N], infact[N];
int t, n, m, k, a[N];

LL qmi(LL a, LL k, LL p) {
    LL res = 1;
    while (k) {
        if (k & 1) res = res * a % p;
        k >>= 1;
        a = a * a % p;
    }
    return res;
}

// 预处理
void init() {
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = (LL)fact[i - 1] * i % mod;
        infact[i] = (LL)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
}
LL res;

int main() {
    init();
    cin >> t;
    while (t--) {
        scanf("%d%d%d", &n, &m, &k);
        res = 0;
        for (int i = 0; i < n; i++) scanf("%d", a + i);
        sort(a, a + n);
        for (int i = 0; i < n; i++) {
            int pos = upper_bound(a, a + n, a[i]+k) - a - 1;
            if (pos - i + 1 < m) continue;
            res = (res + (LL)fact[pos - i ] * infact[m-1] % mod *
                   infact[pos - i + 1 - m] % mod) % mod;
        }
        printf("%lld\n", res);
    }
    return 0;
}

F.The Treasure of The Segments

题意: 给出n个区间,问最少需要删去多少个区间,使得剩下的区间满足至少有一个区间和其他所有剩下的区间都相交

题解: 和区间i不相交的区间j满足:j的右区间小于i的左区间 或者 j的左区间大于i的右区间。所以只需要两次按照端点排序,分别二分即可

代码:

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;
typedef long long LL;
int t, n, temp[N];
struct node {
    int l, r, ln, rn;
} a[N];

bool cmpl(node a, node b) { return a.l < b.l; }
bool cmpr(node a, node b) { return a.r < b.r; }
int main() {
    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> a[i].l >> a[i].r;
            a[i].ln = a[i].rn = 0;
        }
        sort(a, a + n, cmpl);
        for (int i = 0; i < n; i++) {
            temp[i] = a[i].l;
        }
        for (int i = 0; i < n; i++) {
            int pos = upper_bound(temp, temp + n, a[i].r) - temp;
            a[i].rn = n-pos;
        }
        sort(a, a + n, cmpr);
        for (int i = 0; i < n; i++) {
            temp[i] = a[i].r;
        }
        for (int i = 0; i <n; i++) {
            int pos = lower_bound(temp, temp + n, a[i].l) - temp-1;
            a[i].ln = pos + 1;
        }
        int res = 0x3f3f3f3f;
        for (int i = 0; i < n; i++) {
            res = min(a[i].ln + a[i].rn, res);
        }
        cout << res << endl;
    }
    return 0;
}
Dify 进阶指南 | 5步打造智能JSON转换器(Excel数据预处理神器) 本文详细介绍了如何利用Dify平台的Chatflow功能,通过5个步骤构建一个智能JSON转换器,专门用于Excel数据预处理。该工具能够根据用户指令自动解析Excel表格,执行数据清洗、聚合计算,并精准输出定制化的JSON格式,极大提升前端开发、数据分析与测试工作的效率。 阅读详情

相关推荐

RK3568(buildroot)利用squashfs+overlay实现嵌入式系统高可靠存储方案

本文详细介绍了在RK3568嵌入式平台上,基于Buildroot系统,利用squashfs只读根文件系统与overlayfs可写层相结合的高可靠存储方案。该方案能有效防止设备意外断电导致的系统文件损坏,通过内核配置、启动脚本编写及镜像制作,实现系统核心的只读保护与用户数据的持久化分离,显著提升嵌入式设备的现场稳定性。

weixin_29189381的博客 552

Codeforces Round #690 (Div. 3)(D-F)

比赛链接:http://codeforces.com/contest/1462 D. Add to Neighbour and Remove 大意:给定一个数组a,每次可以任选数组中的一个数加到这个数的相邻的一个位置上的数去,然后再将这个数从数组中删去,问使得数组的所有元素相等的最少操作数。 思路:首先知道的是,最多操作n-1此使得最后剩下一个元素。而不管怎么操作,最后所有数的和是不变的,假设是sum,然后去枚举最后剩余多少个元素,假设是i个,那么这些元素都应该等于sum/i,然后去检查是否可以通过上

qq_46653910的博客 238

Xilinx Vivado LDPC IP core,TSN IP core. 各种IP core

Xilinx Vivado LDPC IP core,TSN IP core. 各种IP core

qq_1432825237的博客 3994

Codeforces Round #690 (Div. 3) 题解(A-E2)

文章目录A. Favorite Sequence题目input & output题意思路代码B. Last Year's Substring题目input & output题意思路代码C. Unique Number题目input & output题意思路代码D. Add to Neighbour and Remove题目input & output题意思路代码E2. Close Tuples (hard version)题目input & output题意思路代码E

一只小蒟蒻的博客 1305

Qt多线程实战:如何优雅地处理Modbus设备通信中的线程安全问题

本文深入探讨了在Qt框架下实现Modbus设备通信时的多线程安全问题,提供了优雅的解决方案。通过生产者-消费者模型、任务队列与锁机制等设计模式,有效解决了界面卡顿、数据包错乱等问题。文章还详细介绍了对象生命周期管理、信号槽连接类型选择等关键实现细节,帮助开发者构建稳定可靠的Modbus通信模块。

weixin_30897233的博客 489

数据结构与算法 —— 最短路径Dijkstra算法(迪杰斯特拉)详细图解以及python实现

前两章我们讲到了关于图的基本知识,和广度/深度优先搜索。本章,我们将介绍加权图和最短路径的相关知识。最短路径和最小生成树是图论中常见的问题。最短路径是指在一个图中找到两个节点之间的最短路径,最小生成树是指在一个图中找到一个连通子图,使得所有节点都能够互相到达,且总权值最小。最短路径算法常见的有floyd算法(弗洛伊德算法)和 dijkstra算法(迪杰斯特拉)。本文只介绍dijkstra算法。最短路径运用非常广泛,比如在导航系统中,确定两个地点间哪条路线最短;

‘’ 2万+

Codeforces Round #690 A题 题解

Codeforces Round #690 A题 题解及思考 A. Favorite Sequence time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Polycarp has a favorite sequence a[1…n] consisting of n integers. He wrote it out on the whiteboa

u014517277的博客 295

SAP 财务接口开发:完全清账 vs 标准过账的 CO-PA(获利能力字段) 赋值全解析(含设计哲学)

用于完全清账场景:用于标准凭证过账/部分清账两者对 CO-PA 数据的传递方式截然不同。本文不仅提供完整的代码实现,更深入解析为什么 SAP 要这样设计——了解设计哲学,才能灵活应对各类需求。完全清账→ 调用,必须在T_FTPOST中传递,其他特征用BSEG-RKE_前缀。标准过账/部分清账→ 调用,在CRITERIA表中传递特征,字段名直接用WERKSARTNR等。SAP 的设计智慧面向不同场景,采用不同机制,各司其职。通过接口抽象,将复杂的 CO-PA 配置逻辑封装在内部,对外提供简洁的调用方式。

Pegasus666的博客 337

Codeforces Round #690 (Div. 3)解题报告

题目链接:https://codeforces.com/contest/1462 以后要坚持补题写题解呀~ A:FavoriteSequence 题目大意 给一个序列,按照序列首尾首尾的取元素 思路 vector简单模拟 AC代码 #include <bits/stdc++.h> using namespace std; #define ll long long int a[305]; int main(){ int t; cin >> t; wh.

weixin_43911947的博客 1589

看28377代码笔记

使用的是20MHz外部晶振,为取200MHz系统时钟,倍频设为20,分频设为2,这样sysclock = 20MHz * 20 / 2,正好200MHz。注意:SPISTE配置成普通的GPIO端口,是为了更好控制芯片,配置芯片的时序。FMULT_0:小数点位数,小数只能有0,0.25,0.5,0.75四个选择。XTAL_OSC:表示使用外部晶振。GPIO_MUX_CPU1:复用类型。GPIO_MUX_CPU1:复用类型。PLLCLK_BY_2:表示2分频。IMULT_20:表示倍频数。

小柚子的博客 810

项目篇:移动平台机械臂视觉定位抓取实施(基于ROS架构)

ROS包内容: 这篇日志的目的是快速项目实施,所以详细的部分会不断补充。 1、相机采集包(创建抓取图像服务,单张) Realsense Camera(微软深度摄像头,官方提供ros包) Pylon Camera(basler相机,官方提供ros包) 2、定位算法包(抓取图像,定位标志物) Aruco_ros (二维码定位,官方提供ros包) Apriltag (二维码定位,官方提供ros包)...

南北粉面馆 6052

[leetcode] Two Sum两数之和

Given an array of integers, returnindicesof the two numbers such that they add up to a specific target. You may assume that each input would haveexactlyone solution, and you may not use thesame...

generalsong的博客 187

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Codeforces Round #690 (Div. 3)题解

Codeforces Round #690 (Div. 3) A. Favorite Sequence 题目大意:给定一个输入规律是a1,a3,…,a4,a2a_1,a_3,\dots,a_4,a_2a1​,a3​,…,a4​,a2​的数列,输出原数列 模拟 把给定的数列前n+12\frac{n+1}{2}2n+1​个位置放到答案的奇数位置上,把后面的位置放到答案的偶数位置上即可 #include <bits/stdc++.h> using namespace std; #define IO

DYf3244的博客 257

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round #690 (Div. 3) 题解

A. Favorite Sequence 模拟题 代码 #define LL long long #define pq priority_queue #define ULL unsigned long long #define pb push_back #define mem(a,x) memset(a,x,sizeof a) #define pii pair<int,int> #define fir(i,a,b) for(int i=a;i<=(int)b;++i) #define af

weixin_45590210的博客 350

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Codeforces Round #690 (Div. 3) ABCDE题解

我的博客园传送门 A. Favorite Sequence 思路:照着模拟即可。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #include<map> #include <queue> #include<sstr

待到山花烂漫时 379

Codeforces Round #690 (Div. 3) (简单题解记录)

Codeforces Round #690 (Div. 3) 1462A. Favorite Sequence 简单看懂题即可,左边输出一个然后右边输出一个。 void solve() { int n; cin >> n; vector<ll> a(n + 1); // ll a[n + 1]; //两种写法均可 for (int ...

橘嘉禾 75

【Codeforces 1462】Codeforces Round #690 (Div. 3) | 全题解

阿克快乐,阿克了DIV3 比赛连接:https://codeforces.com/contest/1462 这场比赛蛮简单的. 目录 A. Favorite Sequence 题目大意: 题目思路: Code: B. Last Year's Substring 题目大意: 题目思路: Code: C. Unique Number 题目大意: 题目思路: Code: D. Add to Neighbour and Remove 题目大意: 题目思路: Code: E2.

一只酷酷光儿的博客 566

Codeforces Round #690 (Div. 3) ABCD

A. Favorite Sequence 水题,按题意模拟即可。 #include<bits/stdc++.h> #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl '\n' using namespace std; const int N = 1e5 + 100; int n; int a[N]; vector<int>V; void solve() { cin &

weixin_45925735的博客 169

Codeforces Round #690 (Div. 3) ABC题代码

我比较菜,只能做得出ABC,大佬勿喷 A. Favorite Sequence 模拟即可 #include <bits/stdc++.h> using namespace std; typedef long long ll; int res[512]; int nums[512]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int T; cin >> T; while.

GHY 2279

Codeforces Round #690 (Div. 3)——解题报告

比赛链接:https://codeforces.com/contest/1462 A题——Favorite Sequence 根据题意直接模拟即可。 #include <bits/stdc++.h> #define PI atan(1.0)*4 #define rp(i,s,t) for (register int i = (s); i <= (t); i++) #define RP(i,t,s) for (register int i = (t); i >= (s);.

mumei的博客 246

Codeforces Round #690 (Div. 3)全部题解

总结:这是在cf上打的第二场比赛,做的太慢了,后面几题也没有思路,需要继续刷题 A. Favorite Sequence 先输出一个头部的元素,然后输出一个尾部的元素 如果有奇数个,必然中间会剩余一个,直接输出就好了 #include <bits/stdc++.h> #define lowbit(x) ((x) & (-x)) using namespace std; typedef long long ll; const int N = 2010; int a[N]; int m

Handsomk 443

Codeforces Round #690 (Div. 3) A~F题解

原文链接打着打着,学校停电了,gank了一波,应该是能写的更快的。题意解题思路代码 B 题目链接 题意解题思路代码 C 题目链接 题意解题思路代码 D 题目链接 题意解题思路代码 E1 题目链接 题意解题思路代码 E2也是能写出来的,比赛时没想到,差一点,明天再来跟新。跟新时间 2020-12-17 16:17 原本是打算昨天下午跟新的,室友找我打游戏就咕咕咕了 。 回到正题,比赛期间只看了下E2,没去看F题,其实F题也是很简单的,如果不停电应该能写出来。题意解题思路代码 F 题目链接 题意解题思路代码..

咖喱茴香的博客 1526

Codeforces Round #690 (Div. 3) B

题目链接:https://codeforces.com/contest/1462 B. Last Year’s Substring time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Polycarp has a string s[1…n] of length n consisting of decimal digits. Polycarp perf

weixin_51670469的博客 108

Codeforces Round #690 (Div. 3) A-E2

A. Favorite Sequence 水题,只要按题目要求输出即可。 #include<bits/stdc++.h> using namespace std; #define MULTICASE int _;cin >> _;while(_ --) #define IO ios::sync_with_stdio(false);\ cin.tie(NULL);\ cout.tie(NULL); const int N = 400;

QiPianZuo的博客 293
上一篇: icpc 2019 沈阳区域赛
下一篇: icpc2013长沙区域赛
「已注销」
博客等级 码龄6年 63粉丝 314原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址