Codeforces Beta Round #4 (Div. 2 Only) C. Registration system hash

Matlab Simulink空气涡轮发动机部件级动态仿真模型搭建详解 在航空发动机控制系统设计与故障诊断中,建立高可信度的数字发动机模型是算法验证的基础。部件级模型将进气道、压气机、燃烧室、涡轮、尾喷管等核心部件拆解为独立的气动热力学模块,通过流量、压力、温度与转速等物理量耦合,完整还原发动机的稳态与过渡态特性。相比整机特性图法,部件级模型能精确反映压气机喘振裕度、涡轮前温度超调等关键内部状态,为控制律设计提供物理可解释的反馈信号。在Simulink环境中,利用图形化建模、特性图二维插值、容积模块与转子模块的动态积分,可高效构建此类大规模非线性刚性系统。实际工程中需重点关注设 阅读详情

C. Registration system

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/problemset/problem/4/C

Description

A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on the following principle.

Each time a new user wants to register, he sends to the system a request with his name. If such a name does not exist in the system database, it is inserted into the database, and the user gets the response OK, confirming the successful registration. If the name already exists in the system database, the system makes up a new user name, sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers, starting with 1, are appended one after another to name (name1, name2, ...), among these numbers the least i is found so that namei does not yet exist in the database.

Input

The first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters.

Output

Print n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.

Sample Input

4
abacaba
acaba
abacaba
acab

Sample Output

OK
OK
abacaba1

OK

题意:给定N个字符串,对于每个字符串如果之前出现过,输出出现的次数,否则输出OK。

题解:BKDRhash,map存储次数即可。

AC代码:

/*
* @Author: 王文宇
* @Date:   2018-06-25 23:52:54
* @Last Modified by:   王文宇
* @Last Modified time: 2018-06-26 00:08:51
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100006;
const ll mod = 1998585857;
const int k = 131;
#define _for(i,a,b) for(int i=a;i<=b;i++)
int n;
char s[maxn];
map<ll,int> Q;
ll getnum(char *s)
{
	ll ans = 0;
	while(*s)
	{
		ans=(ans*k+(*s++)+mod)%mod;
	}
	return ans%mod;
}
int main(int argc, char const *argv[])
{
	cin>>n;
	_for(i,1,n)
	{
		cin>>s;
		ll now = getnum(s);
		if(!Q.count(now))
		{
			cout<<"OK"<<endl;
			Q[now]=1;
		}
		else
		{
			cout<<s<<Q[now]<<endl;
			Q[now]++;
		}
	}
	return 0;
}

「大模型学习」(11)kv cache与vllm详解,一文读懂! Key(键):表示上下文的特征。Value(值):表示上下文的内容。Query(查询):表示当前 token 的查询向量。AttentionQKVsoftmaxQKTdkVAttentionQKVsoftmaxdk​​QKT​V),每次生成一个新 token(比如下一个词),模型会再次查看之前的所有K和V,以计算当前 token 的注意力。问题:每次都重新计算之前的 K/V 很浪费!项目维度(简化)含义Q当前 token 的查询向量。 阅读详情

相关推荐

经典蓝牙中的Sniff、Hold与Park模式

若主设备在Sniff Attempt窗口外发送数据,从设备无法接收,需依赖重传机制。移动时立即传输数据。:Sniff Interval=20ms,Attempt=1时隙。:传感器每2秒唤醒一次同步信标,主设备按需唤醒特定传感器采集数据。Slave进入Sniff模式:每20ms唤醒1个时隙监听数据。:设备需要短暂执行高优先级任务(如扫描其他蓝牙设备)。:无数据传输超时后,设备可能自动进入Sniff模式。:主设备通过信标唤醒从设备,或从设备主动请求退出(:平衡功耗与响应速度,适合间歇性数据传输设备。

shishuangquan111的博客 1673

Visual C++注册

<br /> <br /> <br />从微软官网下载的Visual C++ 2010 Express(学习版)默认的测试时间是30天.如果希望长期使用需要注册.<br />该版本的注册是免费的,需要填写注册信息后即可免费获取.<br />具体方法如下:<br /> <br /> 1、打开Visual C++ 2010 Express,选择Help->Regester Product(帮助-产品注册),然后选择Obtain a registration key online(在线获取注册信息)。此处有提示,

计算机视觉之光 1万+

autodl云服务器使用中的conda源报错

通过find path -name filename找到.condarc文件,在autodl服务器中,一般在/root/.condarc。为了利用jypyter打开conda虚拟环境运行,需要下载ipykenel。这个报错是源的问题,在通过源获取包元数据时出现了HTTP 429错误。通过conda换源解决。修改.condarc文件,命令: vim .condarc。但这样还不能解决问题,得把报错中有问题的源注释掉。通过以下命令添加清华镜像源。把报错的链接源注释如下。

Ty_kilig的博客 1584

【无标题】

Visual Studio(简称 VS)是宇宙最强大的编译器,没有之一。Visual C++(简称 VC)是 VS 里面的 C/C++ 开发环境,VC2010 学习版(也就是 Express 版)也是当前计算机二级考试 C 语言的官方指定考试环境,不像 VC6 那么过时,也不像 VC2019 那么体积庞大功能繁杂,非常适合初学者使用。学习编程的过程中,英文是躲不开的。为了能尽早的熟悉英文环境,建议安装英文版的开发环境。因此,本文的安装步骤都是以 VC2010 Express 英文版进行讲解的。如果确实需要使

yx5666的博客 3090

Geneformer实战:如何用Hugging Face Transformers快速搭建单细胞转录组分类模型

本文详细介绍了如何使用Geneformer和Hugging Face Transformers快速搭建单细胞转录组分类模型。通过环境准备、数据预处理、模型加载与配置、训练Pipeline构建等步骤,帮助读者掌握基于Transformer架构的单细胞数据分析技术,提升分类准确率和效率。

rl6adventurer的博客 605

python爬虫:采集求职者简历信息并进行人才分析

通过 Python 爬虫抓取求职者简历信息并进行人才分析,可以帮助企业快速筛选和匹配人才。但在实施过程中,必须严格遵守法律法规,确保数据来源合法合规。如果需要更复杂的分析,可以结合自然语言处理(NLP)和机器学习技术,进一步挖掘数据价值。

数据知道的博客 1万+

c题 Registration system

Description A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask y...

weixin_34204057的博客 323

在 SAP S/4HANA 里把 OData Client Proxy 用顺手,借助 Service Consumption Model 2.0 提前打通远程 OData 调用

摘要:本文探讨了在SAP S/4HANA集成开发中调用外部OData服务的解决方案。传统ABAP代码直接调用方式存在诸多不便,而OData Client Proxy提供了更稳定的途径。文章详细介绍了如何通过Service Consumption Model 2.0在SAP BTP生成模型类,并将其移植到SAP S/4HANA进行适配改造,最终注册为可用的OData Proxy Client。该方法适用于较新版本的SAP S/4HANA系统,通过源码替换实现模型转换,为系统集成提供了高效的类型安全调用方案。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1090

C. Registration system(map)

C. Registration system time limit per test5 seconds memory limit per test64 megabytes inputstandard input outputstandard output A new e-mail service “Berlandesk” is going to be opened in Berland in the near future. The site administration wants to launch t

weixin_51713993的博客 201

Prompt进阶2:LangGPT(构建高性能Prompt策略和技巧)--最佳实践指南

Prompt进阶2:LangGPT(构建高性能Prompt策略和技巧)--最佳实践指南

丨汀、的博客 2650

Vue 网络处理 - axios 异步请求的使用,请求响应拦截器(最佳实践)

axios 用来在前端页面发起一个异步请求,请求之后页面不动,响应回来刷新局部.1.为什么不使用 ajax 呢?官方:在 jQuery 中推荐使用 ajax 技术, Vue 里面不推荐使用 jQuery 框架,因此 Vue 更推荐使用 axiox 异步请求库(axios并不是 vue 官方库).2.axios 特性可以从浏览器中创建 XMLHttpRequests可以从 node.js 中创建 http 请求.支持 Promise API.支持拦截请求和响应.转换请求数据和响应数据.

CYK_byte的博客 1万+

Codeforces Beta Round #4 (Div. 2 Only) C. Registration system(hash)

用字典树求还是比较好的。不过hash更方便。#include <bits/stdc++.h> using namespace std;char str[40]; map<pair<int,int>, int> mp; long long p1=171571,p2=151771; long long mod1 = 1e9+7,mod2=1e9+9;pair<int,int> getHash(char

梦幻的蔷薇色 280

大模型量化方法总结

本文主要对大模型量化方法进行了总结,希望对学习大语言模型的同学们有所帮助。 文章目录 1. 前言 2. 模型精度 3. 量化方法 3.1 方法一 3.2 方法二 3.3 方法三

herosunly的博客 1万+

Codeforces Beta Round #4 (Div. 2 Only) C. Registration system【裸hash/map】

C. Registration system time limit per test 5 seconds memory limit per test 64 megabytes input standard input output standard output A new e-mail service "Berlandesk" i...

weixin_30919235的博客 81

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

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

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Codeforces Beta Round #4 (Div. 2 Only) C. Registration system 暴力or 字典树or哈希

http://codeforces.com/problemset/problem/4/C 题意: 一个注册系统,给出n个注册的名字,每次检查数据库中是否存在该名字,如果不存在返回OK,加入数据库,否如果存在在该名字后边加1,2,3,,,....然后加入数据库。 思路: 暴力存储查询可过,用字典数存处名字可过,哈希存储查找可过。 暴力: View Code #include &l...

weixin_34232744的博客 85

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

1.29 Registration System

https://acs.jxnu.edu.cn/problem/CF4C 描述: A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested t

Zhouwen_的博客 1129

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Registration system (南阳理工oj 题目991)

题目链接  http://acm.nyist.net/JudgeOnline/problem.php?pid=991 Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk" is going to be opened in 

JY_xiaoli的博客 427

NYOJ 991 Registration system(map简单应用)

描述 A new e-mail service "Berlandesk" is going to be opened in Berland in the near future.  The site administration wants to launch their project as soon as possible, that's why they  ask you to help...

pxlsdz的博客 609

A - Registration system(map的简单应用)

Registration system A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they a...

Sun 512

vc2010解决方案项目编译顺序_安装及配置 VC2010 的详细步骤

概述Visual Studio(简称 VS)是宇宙最强大的编译器,没有之一。Visual C++(简称 VC)是 VS里面的 C/C++开发环境,VC2010学习版(也就是 Express版)也是当前计算机二级考试C语言的官方指定考试环境,不像 VC6那么过时,也不像 VC2019那么体积庞大功能繁杂,非常适合初学者使用。学习编程的过程中,英文是躲不开的。为了能尽早的熟悉英文环境,...

weixin_29742557的博客 2937
上一篇: 卿学姐的计算几何模板
下一篇: UVAlive 6959 Judging hash
sortmin
博客等级 码龄9年 45粉丝 178原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值