链接: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 同余定理的更多相关文章

  1. poj 2769 Reduced ID Numbers(memset使用技巧)

    Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...

  2. POJ 1465 Multiple (BFS,同余定理)

    id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS   Memory Limit: 32768K T ...

  3. G - Reduced ID Numbers(第二季水)

    Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...

  4. C - Reduced ID Numbers 寒假训练

    T. Chur teaches various groups of students at university U. Every U-student has a unique Student Ide ...

  5. [ACM] POJ 2635 The Embarrassed Cryptographer (同余定理,素数打表)

    The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11978   A ...

  6. POJ 1426 Find The Multiple(数论——中国同余定理)

    题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...

  7. POJ 2635 The Embarrassed Cryptographer (千进制,素数筛,同余定理)

    The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15767   A ...

  8. poj 1651 http://poj.org/problem?id=1651

      http://poj.org/problem?id=1651Multiplication Puzzle   Time Limit: 1000MS   Memory Limit: 65536K To ...

  9. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

随机推荐

  1. C++类与对象(05)

    类是具有惟一标识符的实体:在类中声明的任何成员不能使用extern.auto和register关键字进行修饰:类中声明的变量属于该类,在某些情况下,变量也可以被该类的不同实例所共享. 访问权限用于控制 ...

  2. python中openpyxl的用法【安装,以及一些基本的操作】

    概述 Openpyxl是python中简单易用的操作excel电子表格的一个模块.接下来呢,跟博主一起学习一下吧  ----_<_>_---- 首先先清楚一些excel的基本概念: 在op ...

  3. ubuntu中python3.4安装pip

    这两天碰到在ubuntu中安装pip的问题. 第一种方法 用百度搜索了一下,基本上都是这个命令: sudo apt-get install python3-pip 但是,用这条命令下载速度特别慢. 第 ...

  4. JAVA提高十一:LinkedList深入分析

    上一节,我们学习了ArrayList 类,本节我们来学习一下LinkedList,LinkedList相对ArrayList而言其使用频率并不是很高,因为其访问元素的性能相对于ArrayList而言比 ...

  5. 本地文件与服务器文件同步shell脚本。

    #!/bin/sh read -t 30 -p "请输入项目名:" name echo -e "\n" echo "项目名为:$name" ...

  6. 修改Jupyter notebook的启动目录

    修改Jupyter notebook的启动目录 1. 在控制台输入以下命令,检查Jupyter notebook的安装目录 jupyter notebook --generate-config ​ 如 ...

  7. 树莓派链接WiFi设置

    树莓派摆脱网线的束缚 在看这篇文章之前,请确保自己树莓派OS已经正常安装且已经连接网线,然后准备一个无线网卡,开始实现我们的树莓派摆脱网线的束缚吧 ! -_- 一.    安装网卡驱动 1.      ...

  8. HDU1166 敌兵布阵(线段树)

    C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况.由于 ...

  9. Maple trees(最小覆盖圆)

    Maple trees Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...

  10. javascript中的变量、作用域和内存问题

    1.变量 变量的值的类型:基本类型值和引用类型值两种. 基本类型:Undefined.Null.Boolean.String.Number,这五类基本数据类型的值在内存中占有固定大小的空间,因此保存在 ...