
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
count=0
sum=0
for i in range(n):
sum+=a[i]
if(sum>=k):
count+=1
sum=0
else :
if(i==n-1):
count+=1
print(count)
墨衍会员
·
AI 创作全网分发
墨衍智能分发
本文由作者通过墨衍一键同步至各平台
1分发平台
100+累计阅读
184平均单平台
已同步平台
优快云
微信公众号
微博
知乎
掘金
百家号
博客园
抖音
小红书
你的文章也可以这样分发
墨衍会员 ¥399起/年,写一次发全网
我也要 →
码龄10年

n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
count=0
sum=0
for i in range(n):
sum+=a[i]
if(sum>=k):
count+=1
sum=0
else :
if(i==n-1):
count+=1
print(count)
别再凭感觉选电容了!手把手教你计算电机控制器里的母线电容(附Excel计算工具)
本文详细解析了电机控制器中母线电容的选型方法,从理论计算到工程实践,帮助工程师避免常见误区。通过精确计算纹波电压、电容容量等关键参数,并结合薄膜电容与电解电容的性能对比,提供实用的选型建议。附带的Excel计算工具可快速完成参数计算,适用于工业伺服驱动和电动车电机控制器设计。
Python-CSP 201703-1 分蛋糕
CSP 201703-1 分蛋糕
PYTHON 打印三角形大全
用PYTHON语言打印各种三角形
CCF 201703-1 分蛋糕 python 满分
CCF 201703-1 分蛋糕 python 满分题目叙述问题描述:略输入格式:略输出格式:略样例满分证明解题思路满分代码 题目叙述 问题描述:略 输入格式:略 输出格式:略 样例 样例输入 6 9 2 6 5 6 3 5 样例输出 3 满分证明 解题思路 注意最后的判定条件: 直到小明的蛋糕分完或者这个朋友分到的蛋糕的总重量大于等于k 后面检查ss是否为空 满分代码 n, k = [eval(x) for x in input().split()] ll = [eval(x) for x in in
SPI模式下的SD卡读写,为什么你的数据总出错?详解时序与状态机避坑指南
本文深入探讨SPI模式下SD卡读写数据出错的根本原因,提供时序优化与状态机设计的实战指南。针对时钟周期计数、状态机跳转和忙检测等核心问题,详解命令时序细节、状态机同步策略及高级避坑技巧,帮助开发者提升SD卡在SPI模式下的稳定性和性能。
MounRiver避坑实录:手把手迁移CH32V307 EVT工程到自定义目录
本文详细记录了将沁恒CH32V307的EVT工程迁移到自定义目录的完整流程与避坑指南。针对MounRiver Studio的虚拟链接机制,重点讲解了如何清理旧配置、重新设置头文件路径、链接脚本等关键步骤,帮助开发者创建独立、可维护的MCU项目工程。
CCF&Python 2017-3-1 分蛋糕
CCF&Python 2017-3-1 分蛋糕原题目思路备注 原题目 思路 一次往后加,大于了k,就清零,计数加一。直到分完 n,k=map(int,input().split()) num_list=list(map(int,input().split())) result=0 temp=0 for i in range(n): temp=temp+num_list[i] ...
SAP Script表单开发中ABAP preform方法的实战应用与调试技巧
本文深入探讨了在SAP Script表单开发中调用ABAP程序(preform方法)的实战应用与调试技巧。通过一个获取供应商版本名称的实例,详细讲解了如何在SE71中嵌入PERFORM指令、编写ABAP子程序进行数据查询与处理,并重点介绍了使用SAP Script Debugger进行高效调试的方法,帮助开发者灵活扩展表单功能,实现复杂业务逻辑。
CCF — 分蛋糕(Python实现:100分)
2017.03.1 分蛋糕 目录 前言 一、问题描述 二、问题分析 三、程序说明 前言 最近我在做CCF的题目,也打算把每道题的解题思路都写到博客上来,希望能帮助到也在做CCF题目的读者们,希望你们通过本文能有所提示,帮助大家提升编程能力。另外有个很好的想法就是,建议读者们可以先看一下问题分析的部分,然后自己再整理一下思路,重新做一遍,最后再参考代码,我想这样会更有收获。 一...
手把手教你学Simulink--巴特沃斯滤波器设计与实现仿真
巴特沃斯滤波器的设计目标是拥有尽可能平滑的通带响应,这意味着在通带内信号衰减最小且没有波动。这种类型的滤波器非常适合用于音频处理、生物医学信号处理以及其他需要高保真度的应用场景。根据应用需求的不同,可以选择低通、高通、带通或带阻滤波器。明确你的系统需求,如输入信号类型(正弦波、方波等)、滤波器类型(低通、高通、带通或带阻)、截止频率、滤波器阶数等。假设我们需要设计一个4阶低通巴特沃斯滤波器,其截止频率为1kHz,用来过滤掉高于1kHz的所有频率成分。
10万张数据集持续迭代:YOLO模型的场景专属自进化体系如何搭建?
做工业质检的朋友应该都有过这样的经历——拿着在COCO上刷榜的YOLO模型跑到产线上一测,精度直接腰斩。这不是模型不行,是场景不对口。过去一年,我深度参与了一个工业视觉项目:产线每天产生超过10万张图像,需要持续迭代检测模型。我们踩过无数坑,最终摸索出一套YOLO模型的场景专属自进化体系。今天不聊虚的,直接上干货。让模型在真实场景数据中持续学习、自动进化,而不是每次依赖人工标注从头训练。下面我从主动学习筛选、增量持续学习、架构选型、部署优化、安全防护五个维度,拆解整个搭建过程。声明。
CCF模拟题——分蛋糕1(Python)
一、 问题描述 试题编号: 201703-1 试题名称: 分蛋糕 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 小明今天生日,他有n块蛋糕要分给朋友们吃,这n块蛋糕(编号为1到n)的重量分别为a1, a2, …, an。小明想分给每个朋友至少重量为k的蛋糕。小明的朋友们已经排好队准备领蛋糕,对于每个朋友,小明总是先将自己手中编号最小的蛋糕分给他,当这个朋友所分得蛋糕的重量不...
ET2012新版免狗免安装绿色软件
ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,
CCF 201703-1 分蛋糕(Python100分)
CCF历届真题 部分题解 ,点击进入 问题描述 试题编号: 201703-1 试题名称: 分蛋糕 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 小明今天生日,他有n块蛋糕要分给朋友们吃,这n块蛋糕(编号为1到n)的重量分别为a1,a2, …,an。小明想分给每个朋友至少重量为k的蛋糕。小明的朋友们已经排好队准备领蛋糕,对于每个朋友,小明总是先将自己手中编号最小的蛋糕分给他,当这个朋友所分得蛋糕的重量不到k时,..
C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片
基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正
复分析 阿尔福斯(Ahlfors) 第三版答案 英文
答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案
CCF Python题解(100分)201703-1 分蛋糕
n, k = map(int, input().split()) weights = list(map(int, input().split())) count = 0 getw = 0 for i in weights[:]: getw += i weights.remove(i) if getw >= k or len(weights) == 0: ...
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
CCF201703-1 分蛋糕(100分)【序列处理】
试题编号: 201703-1 试题名称: 分蛋糕 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 小明今天生日,他有n块蛋糕要分给朋友们吃,这n块蛋糕(编号为1到n)的重量分别为a 1, a 2, …, a n。小明想分给每个朋友至少重量为k的蛋糕。小明的朋友们已经排好队准备领蛋糕,对于每个朋友,小明总是先将自己手中编号最小的蛋糕分给他,当这个朋友所分得蛋糕的重量不到k时,再继续将剩下的蛋糕中编号最小的给他,直到小明的蛋糕分完或者这个朋友分到的蛋糕的总重量大于等于k。 请问当
CCF-CSP认证历年真题解(100分)
转载: 链接出自:https://blog.youkuaiyun.com/tigerisland45/article/details/54755895 CCF-CSP认证历年真题解–python语言 CCF-CSP认证历年真题解–Java语言 C/C++语言: 2019.12 第18次: CCF201912-1 报数(100分)【模拟】 CCF201912-2 回收站选址(100分)【序列处理】 2019.09 第17次: CCF201909-1 小明种苹果(100分)【序列处理】 CCF201909-2 小明种苹果(
python ccf 题解历年100分(2019/08/08更新)
使用python3编写的提交结果为100分的代码 编程中有不合理或改进的地方欢迎评论指出 第一题 python ccf题解 201903-1 小中大 python ccf题解 201812-1 小明上学 python ccf题解 201809-1 卖菜 python ccf题解 201803-1 跳一跳 python ccf题解 201712-1 最小差值 python ccf题解...
CCF-CSP认证历年真题解
程序改变现实,软件统治世界。 程序员需要有精益求精的工匠精神,追求逻辑的极简、时间的最少和存储的最省,并且懂得其中的平衡。 数据表示需要优先考虑,对于许多问题,找到表示该问题的数据结构,问题自然就解决了。 CCF计算机职业资格认证的每一道试题都十分经典,覆盖现实世界中方方面面的问题。这个历年试题解主要使用C/...
CCF认证历年试题解(python版本 + c语言版+c++版本)
试题编号 试题名称 最高得分 试题链接 备注 201809-1 卖菜 100 python 201809-2 买菜 100 python 201809-3 元素选择器 201809-4 再卖菜 201809-5 线性递推式...
python ccf 题解历年100分(9年前两题,共45题)
文章目录一、第一题1.1 2021年 一、第一题 1.1 2021年
CCF认证历年试题
CCF认证历年试题 不加索引整理会死星人orz 第一题: CCF201712-1 最小差值(100分) CCF201709-1 打酱油(100分) CCF201703-1 分蛋糕(100分) CCF201612-1 中间数(100分) CCF201609-1 最大波动(100分) CCF201604-1 折点计数(100分) CCF200512-1 数位之和(100分) C...
ccf csp 201703-1分蛋糕(python)
历年题解 CCF CSP历年题解(python) 样例输入: 6 9 2 6 5 6 3 5 题目链接:201703-1分蛋糕 问题分析: 循环N次,第一个进行累加,累加大于k,初始化,计数加1 满分例程: n,k=input().split() n,k=int(n),int(k) l=list(map(int,input().split())) ch=0 sum=0 for i in range(n): if ch<k: ch+=l[i] else:
CCF201903-2二十四点100分
最近在刷CCF上的题,这道题我研究了好久,查了好多优快云上优秀的文章。基本上思路上我能理解的都是用JAVA和python写的,然而,这代码真心看不懂。。。嘤嘤嘤~~~~ 话说那个用逆波兰式的好高大上啊,好想拥有。。。。 于是,我决定自己研究研究。。。。。 解题思路: 对于这种表达式的题,用堆栈食用更佳。创建一个栈q,遍历表达式的字符串,如果是1到9的数字则入栈;如果遇到乘法和除法符号,...
2021/10/09码加加模拟赛Day3
A.题斐波那契 解题思路 水题,打表解决,递归最后一组测试样例会超时。还有大家读题的时候看一下数据范围啊,忽略了不就没分了? #include<iostream> #include<cstdio> using namespace std; int main() { cin>>n; int f[40]; f[0]=0; f[1]=1; for(int i=2;i<40;i++) //打表,先把数据范围内的所有数据算出来。 { f[i]..
ccf202109-1数组推导(python100分)
n = int(input()) a = list(map(int,input().split())) b=set(a)#去除重复的值 print(sum(a)) print(sum(b)) #嗷嗷嗷嗷,python的内置函数就是香,真香!!!!
CCF201712-2游戏
问题描述 有n个小朋友围成一圈玩游戏,小朋友从1至n编号,2号小朋友坐在1号小朋友的顺时针方向,3号小朋友坐在2号小朋友的顺时针方向,……,1号小朋友坐在n号小朋友的顺时针方向。 游戏开始,从1号小朋友开始顺时针报数,接下来每个小朋友的报数是上一个小朋友报的数加1。若一个小朋友报的数为k的倍数或其末位数(即数的个位)为k,则该小朋友被淘汰出局,不再参加以后的报数。当游戏中只剩下一个小朋友...
1082
1万+
451
3万+

被折叠的 条评论
为什么被折叠?



