当前位置:网站首页>Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
2022-07-06 20:50:00 【Python ml】
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int tsize, n, hashTable[10100];
bool isprime(int a){
if(a==1)return false;
for(int i=2;i*i<=a;i++){
if(a%i==0) return false;
}
return true;
}
void insert(int key){
for(int step=0;step<tsize;step++){
int index=(key+step*step)%tsize;
if(hashTable[index]==0){
hashTable[index]=1;
cout<<index%tsize;
return;
}
}
cout<<'-';
}
int main() {
cin>>tsize>>n;
while (!isprime(tsize)) tsize++;
for(int i=0;i<n;i++){
int key;
cin>>key;
if(i!=0)cout<<" ";
insert(key);
}
system("pause");
return 0;
}
边栏推荐
- 基于STM32单片机设计的红外测温仪(带人脸检测)
- Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
- Unity makes AB package
- [weekly pit] information encryption + [answer] positive integer factorization prime factor
- Application layer of tcp/ip protocol cluster
- Recyclerview GridLayout bisects the middle blank area
- Dynamically switch data sources
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
- 电子游戏的核心原理
- 动态切换数据源
猜你喜欢
Rhcsa Road
为什么新手在编程社区提问经常得不到回答,甚至还会被嘲讽?
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
Distributed ID
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
What key progress has been made in deep learning in 2021?
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
(工作记录)2020年3月11日至2021年3月15日
New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
【微信小程序】运行机制和更新机制
随机推荐
Rhcsa Road
“罚点球”小游戏
2022 nurse (primary) examination questions and new nurse (primary) examination questions
[weekly pit] output triangle
[DIY]自己设计微软MakeCode街机,官方开源软硬件
Web开发小妙招:巧用ThreadLocal规避层层传值
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
小孩子学什么编程?
How to turn a multi digit number into a digital list
基于STM32单片机设计的红外测温仪(带人脸检测)
02 basic introduction - data package expansion
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
Solution to the 38th weekly match of acwing
#yyds干货盘点#重新梳理箭头函数的this
R语言可视化两个以上的分类(类别)变量之间的关系、使用vcd包中的Mosaic函数创建马赛克图( Mosaic plots)、分别可视化两个、三个、四个分类变量的关系的马赛克图
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
Summary of different configurations of PHP Xdebug 3 and xdebug2
2110 summary of knowledge points and common problems in redis class