SGU 127 Telephone directory (模拟)

华为ENSP完整安装教程 阅读详情

time limit per test: 0.5 sec. 
memory limit per test: 4096 KB

http://acm.sgu.ru/problem.php?contest=0&problem=127

CIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory contain the name of the directory and instructions for agents, telephone number records begin on the third page. Each record takes exactly one line and consists of 2 parts: the phone number and the location of the phone. The phone number is 4 digits long. Phone numbers cannot start with digits 0 and 8. Each page of the telephone directory can contain not more then K lines. Phone numbers should be sorted in increasing order. For the first phone number with a new first digit, the corresponding record should be on a new page of the phone directory. You are to write a program, that calculates the minimal number P pages in the directory. For this purpose, CIA gives you the list of numbers containing N records, but since the information is confidential, without the phones locations.

Input

The first line contains a natural number K (0 < K < 255) - the maximum number of lines that one page can contain. The second line contains a natural N (0 < N < 8000) - number of phone numbers supplied. Each of following N lines contains a number consisting of 4 digits - phone numbers in any order, and it is known, that numbers in this list cannot repeat.

Output

First line should contain a natural number P - the number of pages in the telephone directory.

Sample Input

5
10
1234
5678
1345
1456
1678
1111
5555
6789
6666
5000

Sample Output

5

ceil(x / k) = (x - 1) / k + 1 (x!=0)


完整代码:

/*15ms,835KB*/

#include<cstdio>
#include<cmath>

int has[8];

int main(void)
{
	int k, n, count = 2, num;
	scanf("%d%d", &k, &n);
	while (n--)
	{
		scanf("%d", &num);
		if (num < 1000 || num > 7999)
			continue;
		++has[num / 1000];
	}
	for (int i = 1; i < 8; ++i)
		if (has[i])
			count += (has[i] - 1) / k + 1;
	printf("%d", count);
	return 0;
}

Resource: 5th Southern Subregional Contest. Saratov 2002

matlab电偶极子源码,电偶极子的MATLAB场模拟 电偶极子周围电场电势分布的MATLAB三维模拟Matlab可以用于模拟四维场的效果,本文以电偶极子的电场和电势场为例展示MATLAB在该方面领域的应用。摘要电偶极子由一个正电荷和一个负电荷组成,其电场和空间电势分布与单电荷相比具有一些重要的特性。本文将给出电场和电势场的近似表达式。这两个量的精确表达式是复杂的,不太常用,因此 MATLAB 被采用来操作精确值和绘制三维分布的远区域, 近区域和一侧区... 阅读详情

相关推荐

vtk相机_分别用 VTK 体绘制和面绘制来实现医学图像三维重建;

序言,VTK介绍:VTK 全称为 The Visualization Toolkit (可视化工具),是一个开源、跨平台、自由获取、支持并行计算的图形应用函数;拥有3D 渲染的最新工具、提供3D交互模式以及2D绘图等。VTK 包含一个C++类库,目前提供了众多语言接口,例如 Java、Python、TCL;在三维函数库OpenGL 的基础上采用面向对象设计方法发展起来图形学基本概念和数据...

weixin_39665302的博客 687

模拟/sgu 127 Telephone directory

题意   给出n个四位数组成的电话号,要求安排在一个电话本里,从第三页开始安排。使得每一页都是一个数字开头的电话号,且每一页不超过k个;如超过了,则新开一页记录 分析   无聊的题。开个数组记录每个数字开头的号码有多少个,然后利用div k记录答案,如果不是整除,则再加一页   注:答案+2 Accepted Code 1 /* 2 PROBLEM:sgu1...

dkkzxga4442的博客 176

合金理论自动化工具包(Alloy-Theoretic Automated Toolkit:ATAT)的安装

合金理论自动化工具包(ATAT)是一个通用名称,指的是合金理论工具的集合,它包含了不同的代码工具,具体如下: 1)根据第一性原理(映射和映射)构造集群扩展的代码。簇展开是一种非常紧凑和有效的表达式,给出取代合金的能量作为其构型的函数(即原子的类型位于晶格的哪个位置)。 2)为了计算合金的热力学性质,从聚类展开开始,对晶格模型进行蒙特卡洛模拟(emc2和memc2)的代码。 3)执行晶格动力学计算的代码(fitfc, fitsvsl, svsl) 4)使用简单的物理或半经验模型计算电子和磁自由能贡献

qq_33400046的博客 1万+

SGU 127. Telephone directory --- 模拟

<传送门> 127. Telephone directory time limit per test: 0.25 sec.memory limit per test: 4096 KB CIA has decided to create a special telephone directory for its agents. The first 2 pages of th...

weixin_33941350的博客 69

手把手教你用6轴IMU跑通LIO-SAM:参数配置与代码修改保姆级教程

本文提供了一套完整的6轴IMU适配LIO-SAM的解决方案,包括参数配置与代码修改的详细步骤。从理解6轴与9轴IMU的关键差异入手,逐步指导如何调整核心配置文件params.yaml、重构utility.h关键函数、优化mapOptimization.cpp的位姿融合逻辑,并给出编译验证与性能调优建议,帮助开发者快速实现6轴IMU在LIO-SAM中的稳定运行。

weixin_28717807的博客 357

C# 开发 ACS 运动控制系统:从入门到高阶应用实践

起始位置</param>/// <param name="endPos">结束位置</param>/// <param name="maxVelocity">最大速度</param>/// <param name="maxAcceleration">最大加速度</param>/// <param name="maxJerk">最大加加速度

品质生活,极致编程。 2842

SGU127 Telephone directory

有一本电话簿,前两页是目录,每页可记录K条电话信息 现在有N条电话信息,要求按照号码排序,且电话号码首位不同的信息不能在同一页 问电话簿至少要有多少页

╮(╯▽╰)╭ 468

MLC-LLM框架在安卓设备上的模型编译与部署全流程解析

本文详细解析了如何利用MLC-LLM框架在安卓设备上编译与部署大语言模型。从环境搭建、模型获取与量化编译,到最终的安卓应用打包与调试,提供了完整的实战流程。重点介绍了如何通过MLC-LLM将大型模型优化为适合移动端运行的格式,实现本地、低延迟、隐私安全的AI应用部署。

weixin_29251337的博客 475

SGU[127] Telephone directory

Description 描述 CIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory contain the name of the directory and instructions for agents, telephon...

asd5215208的博客 163

RKNN 端侧部署必看:YOLOv11 Pose 姿态估计模型转换与性能优化实战

随着人工智能技术在边缘计算领域的快速发展,姿态估计作为计算机视觉的重要分支,在智能监控、人机交互、体感游戏等场景中展现出巨大的应用潜力。本文深入研究了YOLOv11 Pose模型在Rockchip RKNN平台上的部署方案,从理论基础、模型转换、平台优化到实际部署进行了全面阐述。通过详细的技术分析和实验验证,证明了RKNN平台能够有效提升YOLOv11 Pose的推理性能,在RK3588硬件平台上实现了高达100 FPS的实时姿态检测,为边缘计算场景下的姿态估计应用提供了高效的解决方案。

m0_71589036的博客 183

【Google Play 上架】内部 / 封闭 / 开放 测试全解 — “只跑一个就能上架”?不行!

Google Play新规要求个人开发者账号在2023年11月13日后必须通过封闭测试(Closed testing)才能上架应用。封闭测试需要至少12名测试者连续14天保持参与状态,而内部测试和开放测试不能替代这一要求。三类测试轨道各有特点:内部测试用于快速内部验证,封闭测试是上架必经环节,开放测试面向更广泛用户但非必需。上架流程建议先内部测试修复问题,再启动封闭测试满足14天要求,最后申请生产发布。组织账号和早期个人账号可能不受此限制。开发者应提前规划测试人群,确保持续测试周期,并关注Play Cons

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 2799

SGU127-Telephone directory

127. Telephone directory time limit per test: 0.5 sec. memory limit per test: 4096 KB CIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory

丙三醇 1222

IgH EtherCAT 从入门到精通:第 19 章 主站状态机(FSM)深度解析

文章摘要:IgH EtherCAT主站采用多层次有限状态机(FSM)架构实现总线管理。核心是Master FSM,负责总线扫描、从站配置和邮箱通信,通过函数指针状态机模式实现异步非阻塞操作。系统包含多个嵌套FSM:Slave FSM管理单个从站请求,Slave Scan FSM处理拓扑变化扫描,Slave Config FSM配置从站状态转换,Change FSM执行AL状态切换。这种设计通过状态函数指针转换实现复杂协议交互,各FSM协同工作完成EtherCAT网络的初始化、配置和实时通信,支持热插拔和错误

从事嵌入式linux android驱动开发,拥有全栈能力 146

sgu 127. Telephone directory

127. Telephone directorytime limit per test: 0.25 sec. memory limit per test: 4096 KBCIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory contain ...

superkunn的博客 264

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

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

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

sgu127:Telephone directory

水题啊,统排过 代码如下:

qq_20118433的专栏 506

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

SGU 127 Telephone directory

#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef _WIN32 #define i64 __int64 #define out64 "%I64d\n" #de

量子流逝 565

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[SGU]127. Telephone directory

Analysis     还是一道大水题……对于每个数字统计出以它为第一位的号码的个数,然后模一下加一下就可以了。 Accepted Code var a:array[0..9] of longint; k,n,i,ans:longint; s:string; begin readln(k); readln(n); fillchar(a,

Jerry I. Huang 586

sgu 127 Telephone directory

127. Telephone directory time limit per test: 0.5 sec. memory limit per test: 4096 KB CIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory c

utoppia is another word . 496

SGU 127 Telephone directory(水~)

Description 有n个四位数的电话号码,现要将这些电话号码写进电话本里,电话本的每一页只能写第一个数字相同的电话号码,且每页至多写k个,问将这些电话号码写进电话本中至少需要写几页 Input 第一行为一整数k表示每页能够写的电话号码数量,第二行一整数n表示电话号码数量,之后n行每行一个四位数表示一个电话号码 Output 输出将这些电话号码写进电话本中至少需要写几页 Sample

ZSQ 606

SGU - 127 - Telephone directory (水~)

127. Telephone directory time limit per test: 0.25 sec.  memory limit per test: 4096 KB CIA has decided to create a special telephone directory for its agents. The first 2 pages of the direct

Never say never 936

SGU 127. Telephone directory

看懂题目!!!!!! #include using namespace std;int main() { int k, n; int a[10] = {0}; scanf("%d %d", &k, &n); int temp; for(int i = 1; i <= n; i++) { scanf("%d", &temp); a[temp/100

355

快速切题sgu127. Telephone directory

127. Telephone directory time limit per test: 0.25 sec.memory limit per test: 4096 KB CIA has decided to create a special telephone directory for its agents. The first 2 pages of the dir...

weixin_30807677的博客 134

UVa 414 Machined Surfaces (water ver.)

414 - Machined Surfaces Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=355 An imaging device furnishes di

AC,∑ndless 6714

POJ 1835 宇航员 (模拟&三维向量旋转)

宇航员 http://poj.org/problem?id=1835 Time Limit: 2000MS Memory Limit: 30000K Description 问题描述:    宇航员在太空中迷失了方向,在他的起始位置现在建立一个虚拟xyz坐标系,称为绝对坐标系,宇航员正面的方向为x轴正方向,头顶方向为z轴正方向,则宇航员的初始状态如下

AC,∑ndless 3250

UVa 118 Mutant Flatworld Explorers (模拟机器人移动)

118 - Mutant Flatworld Explorers Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=54 旋转时+1或+3再取模即可。 完整

AC,∑ndless 2570
上一篇: SGU 115 Calendar (模拟)
下一篇: Codeforces Bayan 2012-2013 Elimination Round / 241A Old Peykan (贪心)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值