CodeForces - 165C

别再只画版图了!用ADS RFPro的Circuit模型,快速评估滤波器加电容后的性能变化 本文详细介绍了如何利用ADS RFPro的Circuit模型功能,实现射频滤波器设计中版图与集总元器件的高效协同仿真。通过混合仿真技术,工程师可以快速评估滤波器加电容后的性能变化,大幅缩短设计迭代周期,提升工作效率。文章还提供了实战案例和高级技巧,帮助读者掌握这一创新设计方法。 阅读详情

A string is binary, if it consists only of characters “0” and “1”.

String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string “010” has six substrings: “0”, “1”, “0”, “01”, “10”, “010”. Two substrings are considered different if their positions of occurrence are different. So, if some string occurs multiple times, we should consider it the number of times it occurs.

You are given a binary string s. Your task is to find the number of its substrings, containing exactly k characters “1”.

Input
The first line contains the single integer k (0 ≤ k ≤ 106). The second line contains a non-empty binary string s. The length of s does not exceed 106 characters.

Output
Print the single number — the number of substrings of the given string, containing exactly k characters “1”.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Example
Input
1
1010
Output
6
Input
2
01010
Output
4
Input
100
01010
Output
0
Note
In the first sample the sought substrings are: “1”, “1”, “10”, “01”, “10”, “010”.

In the second sample the sought substrings are: “101”, “0101”, “1010”, “01010”.

这玩意就是找几个零几个一非常容易。。
有点坑的是运算过程一定要*1LL不然过程中就爆了int

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string q;
int n,m=0;
int yi[1000001];
int main()
{
    cin >> n >> q;
//  n = 0;
//  q = "0";
//  for (int a = 1; a <= 99999; a++)q += "0";
    for (int a = 0; a < q.size(); a++)if (q[a] == '1')yi[++m] = a+1;
    if (n == 0)
    {
        long long we = 0;
        for (int a = 1; a <= m; a++)we += 1LL*((yi[a] - yi[a - 1] - 1) + 1)*(yi[a] - yi[a - 1] - 1) / 2;
        we += 1LL * (q.size() - yi[m])*(q.size() - yi[m] + 1) / 2;
        cout << we;
        return 0;
    }
    long long jg = 0;
    for (int a = 1, b = n; a <= m && b <= m; a++, b++)
    {
        if (b == m)
        {
            jg += 1LL * (yi[a] - yi[a - 1])*(q.size() - yi[b]+1);
            continue;
        }
        jg+= 1LL*(yi[a] - yi[a - 1])*(yi[b+1] - yi[b]);
    }
    cout << jg;
}
aubo i5 + realsense D435i识别抓取实践二 aubo i5 + realsense D435i识别抓取实践二前言一、手眼标定是什么?二、标定软件安装1.aruco_ros安装2.vision_visp安装3.easy_handeye安装4.realsense驱动安装5.安装realsense ROS软件包三、配置1.launch文件修改2.打印二维码四、手眼标定1.启动launch文件2.标定步骤3.发布tf关系 前言 前面配置好了aubo机械臂的ROS软件包,机械臂可以正常运行后,接下来我们进行机械臂与相机的手眼标定。手眼标定分为eye_on_ha 阅读详情

相关推荐

麒麟桌面操作系统QT开发环境搭建

麒麟操作系统安装Qt

因为热爱,所以坚持,记录工作中的乐趣 9287

codeforces 165-C. Another Problem on Strings(计数+尺取)

A string is binary, if it consists only of characters “0” and “1”.String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, s

HJ 800

从零到一:Bioconductor新手入门与R包安装实战

本文详细介绍了Bioconductor在生物信息学中的重要性及其R包安装实战指南。从环境准备到BiocManager的使用,再到常见问题排查,帮助新手快速掌握这一强大工具。特别推荐org.Hs.eg.db等核心工具包,助力基因注释和功能分析,提升研究效率。

weixin_29061041的博客 427

Codeforces 165C Another Problem on Strings 【二分】

题目链接:Codeforces 165C Another Problem on Strings C. Another Problem on Strings time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A string i

世界很大 1301

Linux SMP系统多核启动机制详解

对称多处理(SMP)是现代操作系统支持多核并行计算的基础架构。其核心原理是通过引导处理器(BSP)初始化系统环境后,通过处理器间中断(IPI)机制唤醒应用处理器(AP)。在x86架构中,AP启动时处于实模式,需要特殊的trampoline代码完成保护模式切换和分页设置。这种设计既保证了系统初始化的正确性,又实现了多核并行处理的性能优势。理解SMP启动流程对优化系统启动速度和调试多核问题至关重要,特别是在云计算和嵌入式系统中,高效的SMP初始化能显著提升系统响应能力。本文以Linux内核为例,深入解析了从BS

weixin_35006125的博客 298

QuickFix Java 讲解(一)概述、下载方法,和协议内容

本系列力求手把手教你怎样利用QuickFix Java 搭建自己的 FIX 协议收法平台,以及其中的注意事项。 所有源码的地址(免费): https://github.com/zongzhec/QuickFixPractise 1. 什么是FIX,QuickFix,Quick Java? 1.1. 什么是FIX 官网以及其他翻译自官网的帖子都太官方了,这里我们设想一个情景: 你是一个交易员,现在客户打电话来让你下个单买点股票。你啪啪啪的在你的机器上熟练地输入了下单指令。系统显示:成...

4575

cf 165c Another Problem on Strings

给定一个 01 串,求恰好包含 n 个 1 的字串个数。

m0_62542844的博客 414

微生物组β-多样性——PCoA分析及可视化

让你的数据映入眼帘

qq_47369980的博客 1万+

codeforces-165C-Another Problem on Strings

C. Another Problem on Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A string is binary, if it consists only of characte

看起来喜欢做枯燥事情的人或许只是更清楚自己想要什么罢了 585

【2026OD新机考】【不定滑窗】20260415-API请求日志去重分析【Py/Java/C++/C/JS/Go六种语言OD真题】【欧弟算法】全网注释最详细分类最全的华子OD真题题解

中找到所有的连续的相同元素,同时统计对应的连续相同元素对应的值的平均值。:当右指针为第一个元素(没有前一个元素),或者右指针对应的元素。某微服务系统的日志监控平台需分析API调用记录,日志含大量。相等,说明当前元素仍然属于同一个相同元素窗口,将当前元素值。中的所有元素均相等,并且计算窗口和情况即可。请实现一个函数,对给定的日志数据去重合并处理。位置,表示开启一个新的窗口,此时需要重置窗口和。,为了优化重复的请求记录,存储和后续分析需对。:对应的响应时间数组(毫秒)。重新置为当前右指针的元素值。

weixin_48157259的博客 122

基于Requests的百度图片搜索爬取技术详解

本文介绍了一种高效获取百度图片搜索数据的混合请求爬虫技术。该技术结合HTML解析与JSON API调用,通过分析百度图片搜索的网络通信模式,实现了首页HTML解析获取初始参数、后续页面直接调用JSON接口的双重机制。系统采用模块化设计,包含Cookies解析、智能请求分发、数据提取、图片下载等核心模块,支持自定义关键词和爬取页数配置。关键技术包括动态参数管理、正则表达式提取、JSON数据处理等,相比传统爬虫方法具有效率高、资源消耗低的优势,为计算机视觉研究提供了可靠的大规模图片数据采集方案。

那些看似不起波澜的日复一日,会在某天让你看到坚持的意义 427

Another Problem on Strings

A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For exam

码农的一亩三分地 361

TensorRT量化校准数据集选择

在TensorRT中进行INT8量化时,校准数据集的选择至关重要,直接影响量化后模型的精度和推理性能。这是一个典型的问题。

浩瀚之水的专栏 500

Another Problem on Strings CodeForces - 165C

Another Problem on Strings CodeForces - 165C A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can b

codeswarrior的博客 445

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

CodeForces 165C 一个可以过但是没过的题

题目链接:http://codeforces.com/contest/165/problem/C 题意:给你一个有0和1组成的字符串(10^6),问有多少个包含确定k个1的子串。 刚开始没仔细想就放弃了,后来有人过,仔细考虑一下是个水题,首先分情况,当k=0是,k!=0时,然后对每种情况各自处理,第一种情况k=0,那么只需要统计连续0的个数,加到ans中,k!=0是难处理,但是分析思路,我只需

No Pain No Gain 608

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces 165C(二分)

问题描述:A string is binary, if it consists only of characters "0" and "1".String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For exam...

wust_cyl的博客 369

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces 165C Another Problem on Strings(尺取法)

题目 题目链接Problem - 165C - Codeforces C. Another Problem on Strings 2 seconds 256 megabytes A string isbinary, if it consists only of characters "0" and "1". Stringvis asubstringof stringwif it has a non-zero length and can be read sta...

Carry_hkr的博客 368

CodeForces - 165C Another Problem on Strings (前缀)

题目链接:http://codeforces.com/problemset/problem/165/C点击打开链接 C. Another Problem on Strings time limit per test 2 seconds memory limit per test 256 megabytes input standar

xuejye的博客 664

CodeForces 165C - Another Problem on Strings

C. Another Problem on Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A string is binary, if it con

coco430的专栏 1270

CodeForces - 165C Another Problem on Strings 前缀和+二分

题意: 给定一个01串和k,求包含k个1的子串的个数 思路: 用前缀和记录到当前位置的个数,那么就可以知道某个子串的1的个数 我们遍历字符串 对于每个位置i,以他为开头的子串,要求1的个数为k的数量,我们只需要求有多少个值等于sum[i-1]+k就可以了, 枚举肯定不行,因为是前缀和有序,我们二分,两次二分 upper_bound(sum+1,sum+len+1+1,sum[i-1]+k)-low...

青春苦瓜 325

CodeForces 165C Another Problem on Strings

Another Problem on Strings A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from so

galesaur_wcy 523

codeforces 165C Another Problem on Strings 双指针

题意:求对于给定01字符串,有多少个子串,其恰好包含了k个1 双指针,把每个1都找出来,统计这个1之后有多少个0 然后用乘法原理计算 #include #include #include #include #define rep(i, j, k) for(int i = j; i <= k; i++) using namespace std; typedef long

cadongllas的博客 404

Codeforces #165 div2 C. Magical Boxes

C. Magical Boxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Emuskald is a well-known illusionist. One of his tra

hqu_fritz的专栏 636

状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers

解决这类题目的关键是深入了解 |, ^, ! ,& 操作的意义;   codeforces 244 Problem C. The Brand New Function  题目链接: http://www.codeforces.com/contest/244/problem/C 题意: 给出n的数据,连续一段数据做|可产生一个值,问有可产生多少个不同的值? 分析: 首先对|操作进行分析

Welcome To My Blog.... 898

Educational Codeforces Round 165 (Rated for Div. 2) (C、D)

寄寄寄寄摆摆摆摆

weixin_61825750的博客 1345

CodeForces 165C Another Problem on Strings

A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For examp

CS33sun的博客 361
上一篇: CodeForces - 157D
下一篇: CodeForces - 798C
NineFailure
博客等级 码龄11年 22粉丝 317原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值