当前位置:网站首页>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;
}
边栏推荐
- Unity making plug-ins
- 电子游戏的核心原理
- 【每周一坑】计算100以内质数之和 +【解答】输出三角形
- 小孩子学什么编程?
- 性能测试过程和计划
- Maximum likelihood estimation and cross entropy loss
- OLED屏幕的使用
- 过程化sql在定义变量上与c语言中的变量定义有什么区别
- 2022 Guangdong Provincial Safety Officer C certificate third batch (full-time safety production management personnel) simulation examination and Guangdong Provincial Safety Officer C certificate third
- SQL injection 2
猜你喜欢

性能测试过程和计划
![[200 opencv routines] 220 Mosaic the image](/img/75/0293e10ad6de7ed86df4cacbd79b54.png)
[200 opencv routines] 220 Mosaic the image

Redis insert data garbled solution

看过很多教程,却依然写不好一个程序,怎么破?

Variable star --- article module (1)

Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model

Leetcode question 283 Move zero

【每周一坑】信息加密 +【解答】正整数分解质因数

Gui Gui programming (XIII) - event handling

Force deduction brush question - 98 Validate binary search tree
随机推荐
Trends of "software" in robotics Engineering
Mécanisme de fonctionnement et de mise à jour de [Widget Wechat]
(work record) March 11, 2020 to March 15, 2021
Comprehensive evaluation and recommendation of the most comprehensive knowledge base management tools in the whole network: flowus, baklib, jiandaoyun, ones wiki, pingcode, seed, mebox, Yifang cloud,
2022 portal crane driver registration examination and portal crane driver examination materials
Rhcsa Road
C language operators
Yyds dry goods count re comb this of arrow function
Pytest (3) - Test naming rules
Design your security architecture OKR
#yyds干货盘点#重新梳理箭头函数的this
2022 Guangdong Provincial Safety Officer C certificate third batch (full-time safety production management personnel) simulation examination and Guangdong Provincial Safety Officer C certificate third
Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
01 basic introduction - concept nouns
Regular expression collection
Utilisation de l'écran OLED
使用.Net分析.Net达人挑战赛参与情况
PG基础篇--逻辑结构管理(事务)
【每周一坑】信息加密 +【解答】正整数分解质因数
性能测试过程和计划