poj 2769 Reduced ID Numbers 同余定理
链接:http://poj.org/problem?id=2769
题意:寻找数m,是的对于n个数的余数不同
思路:暴力,优化:同余部分不用测试
代码:
#include <iostream>
#include <string.h>
using namespace std;
int ans[],vis[];
int main() {
ios::sync_with_stdio(false);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t,n,i,j,ok;
cin>>t;
while(t--) {
cin>>n;
for(i=; i<=n; ++i) cin>>ans[i];
for(i=; i<; ++i) {
ok=;
for(j=; j<=i-; ++j) vis[j]=;
for(j=; j<=n; ++j) {
if(vis[ans[j]%i]) {
ok=;
break;
}
vis[ans[j]%i]=;
}
if(ok) break;
}
cout<<i<<endl;
}
return ;
}
poj 2769 Reduced ID Numbers 同余定理的更多相关文章
- poj 2769 Reduced ID Numbers(memset使用技巧)
Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...
- POJ 1465 Multiple (BFS,同余定理)
id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS Memory Limit: 32768K T ...
- G - Reduced ID Numbers(第二季水)
Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...
- C - Reduced ID Numbers 寒假训练
T. Chur teaches various groups of students at university U. Every U-student has a unique Student Ide ...
- [ACM] POJ 2635 The Embarrassed Cryptographer (同余定理,素数打表)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11978 A ...
- POJ 1426 Find The Multiple(数论——中国同余定理)
题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...
- POJ 2635 The Embarrassed Cryptographer (千进制,素数筛,同余定理)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15767 A ...
- poj 1651 http://poj.org/problem?id=1651
http://poj.org/problem?id=1651Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K To ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
随机推荐
- C++ 对象成员函数(非静态方法)
1.神奇的inline语法与语义 inline语义C99和C++98都有.之前在单源文件编写的时候一直没有发现问题,但是一考虑到多文件的链接,就发现矛盾了. 一些inline的原则: 1. inlin ...
- Leetcode题解(29)
93. Restore IP Addresses 题目 分析:多重循环,判断小数点合适的位置 代码如下(copy网上) class Solution { public: vector<strin ...
- CodeForces 11D(状压DP 求图中环的个数)
Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no re ...
- Travel
Travel Time Limit: 10000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- HDU 5783 Divide the Sequence (训练题002 B)
Description Alice has a sequence A, She wants to split A into as much as possible continuous subsequ ...
- Ipad,IPhone(矩阵求递推项+欧拉定理)
Ipad,IPhone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- linux的特殊符号与正则表达式
第1章 linux的特殊符号 1.1 通配符 * {} 1.1.1 含义 方便查找文件 通配符是用来找文件名字的. 1.1.2 * 通过find 命令找以 .sh 结尾的文件,使用*替代文件名字. ...
- 0_Simple__simpleAssert + 0_Simple__simpleAssert_nvrtc
在核函数中使用强制终止函数 assert().并且在静态代码和运行时编译两种条件下使用. ▶ 源代码:静态使用 #include <windows.h> #include <stdi ...
- VS2013装扩展RazorGenerator
问题:vs2013工具扩展和更新搜索关键字:Razor Generator查找不到,如图 解决:下载网址:https://github.com/RazorGenerator/RazorGenerato ...
- 无阻赛的脚本(js脚本延迟方法)
js脚本的加载与执行 1.延迟脚本(defer属性) 带有defer属性的script标签,可以放置在文档的任何位置,在页面解析到该标签时,会开始下载该脚本,但是不会立即执行,直到dom加载完成(on ...