当前位置:网站首页>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;
}
边栏推荐
- Dynamically switch data sources
- Regular expression collection
- OSPF多区域配置
- Core principles of video games
- use. Net drives the OLED display of Jetson nano
- Logic is a good thing
- Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
- 【每周一坑】计算100以内质数之和 +【解答】输出三角形
- How to turn a multi digit number into a digital list
- 7、数据权限注解
猜你喜欢

The mail command is used in combination with the pipeline command statement

1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效

Maximum likelihood estimation and cross entropy loss

New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue

Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)

拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条

Use of OLED screen
![[diy] self designed Microsoft makecode arcade, official open source software and hardware](/img/a3/999c1d38491870c46f380c824ee8e7.png)
[diy] self designed Microsoft makecode arcade, official open source software and hardware

use. Net drives the OLED display of Jetson nano

Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
随机推荐
“罚点球”小游戏
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Boder radius has four values, and boder radius exceeds four values
[DIY]自己设计微软MakeCode街机,官方开源软硬件
【每周一坑】输出三角形
性能测试过程和计划
Distributed ID
15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
2022 construction electrician (special type of construction work) free test questions and construction electrician (special type of construction work) certificate examination
Mtcnn face detection
Reinforcement learning - learning notes 5 | alphago
Why do novices often fail to answer questions in the programming community, and even get ridiculed?
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
【微信小程序】運行機制和更新機制
Web开发小妙招:巧用ThreadLocal规避层层传值
Catch ball game 1
"Penalty kick" games
什么是RDB和AOF
Web security - payload
Rhcsa Road