当前位置:网站首页>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;
}
边栏推荐
- 强化学习-学习笔记5 | AlphaGo
- 逻辑是个好东西
- 2022 nurse (primary) examination questions and new nurse (primary) examination questions
- Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
- Rhcsa Road
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
- 基于STM32单片机设计的红外测温仪(带人脸检测)
- Web开发小妙招:巧用ThreadLocal规避层层传值
- C language games - minesweeping
- SQL injection 2
猜你喜欢
PHP online examination system version 4.0 source code computer + mobile terminal
Boder radius has four values, and boder radius exceeds four values
小孩子學什麼編程?
use. Net drives the OLED display of Jetson nano
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
使用.Net分析.Net达人挑战赛参与情况
15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace
Design your security architecture OKR
Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
Gui Gui programming (XIII) - event handling
随机推荐
OAI 5g nr+usrp b210 installation and construction
Infrared thermometer based on STM32 single chip microcomputer (with face detection)
Huawei device command
Web security - payload
Intel 48 core new Xeon run point exposure: unexpected results against AMD zen3 in 3D cache
使用.Net分析.Net达人挑战赛参与情况
Error analysis ~csdn rebound shell error
【微信小程序】運行機制和更新機制
Distributed ID
Simple continuous viewing PTA
Is it safe to open an account in flush? Which securities company is good at opening an account? Low handling charges
Taylor series fast Fourier transform (FFT)
Leetcode question 448 Find all missing numbers in the array
Minimum cut edge set of undirected graph
(work record) March 11, 2020 to March 15, 2021
Comment faire une radio personnalisée
User defined current limiting annotation
JMeter server resource indicator monitoring (CPU, memory, etc.)
小孩子學什麼編程?
Dynamically switch data sources