1078. Hashing (25)
来源:互联网 发布:淘宝摄影师在哪里接单? 编辑:程序博客网 时间:2024/06/06 09:12
题目:https://www.patest.cn/contests/pat-a-practise/1078
代码:
#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> using namespace std; bool isprime(int n){if(n<=1) return false;for(int i=2;i<=n/2;i++){if(n%i==0){ return false;}}return true;}bool temp[11111]={0};int main() { int msize,n,t;scanf("%d%d",&msize,&n); while(isprime(msize)==false){ msize++;}for(int i=0;i<n;i++){ scanf("%d",&t); int s=t%msize; if(temp[s]==false){ temp[s]=true; if(i==0)printf("%d",s); else printf(" %d",s); }else{ int j; for(j=1;j<msize;j++){ s=(t+j*j)%msize; if(temp[s]==false){ temp[s]=true; if(i==0)printf("%d",s); else printf(" %d",s);break; } } if(j>=msize) { if(i>0) printf(" "); printf("-"); } }} system("pause"); }
0 0
- 1078. Hashing (25)
- PAT 1078. Hashing (25)
- pat 1078. Hashing (25)
- PAT 1078. Hashing (25)
- PAT 1078. Hashing (25)
- 1078. Hashing (25)
- 1078. Hashing (25)
- 1078. Hashing (25)
- 1078. Hashing (25)
- 1078. Hashing (25)
- PAT 1078. Hashing (25)
- PAT 1078. Hashing (25)
- 1078. Hashing (25)
- PAT 1078. Hashing (25)
- 1078. Hashing (25)
- 【PAT】1078. Hashing (25)
- 1078. Hashing (25)
- 1078. Hashing (25)
- 404. Sum of Left Leaves [LeetCode]
- JAVA开发过程中使用第三方jar(未完待续)
- scrapy抓取一个电影网站信息
- shell脚本运行方式和对环境变量的影响
- IOS与React Native混编,将RN框架使用CocoaPods集成到原生项目中
- 1078. Hashing (25)
- 前端防止按钮被多次点击
- 用Web api /Nancy 通过Owin Self Host简易实现一个 Http 服务器
- Android Volley 发送请求Demo
- (二)Lua脚本语言入门
- tensorflow基础学习笔记
- 如何使用水果编曲软件预处理效果
- 【PAT】1081. Rational Sum
- Java时间戳