链接: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. Acitiviti笔记(一)

    一.核心组件 ProcessEngine:流程引擎的抽象,对于开发者来说,它是我们使用Activiti的facade,通过它可以获得我们需要的一切服务.类似于一个容器工厂,来保存创建的ProcessE ...

  2. LeetCode 566. Reshape the Matrix (重塑矩阵)

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  3. 关于对vector3及其衍生变量的理解

    关于对vector3,vector2类及其衍生变量的理解 vector3简单来讲即表示向量和点的系统类,这个结构用于处理向量和点,也包含许多做向量运算的函数. 而vector2即少一维向量的类,用于处 ...

  4. iOS之 git 简单使用

    之前没有用过git管理代码, 现在 公司要求使用git,咱 就 记记 今天所学的东西.以后也好方便查阅 和补充. 首先 我描述一下我今天提交代码的情况. 同伴给了我一个 从git库下来的2个项目的包. ...

  5. Codeforces 378B. Parade

    B. Parade time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  6. idea tomee required to support ear ejb deployment问题

    先删掉原来的uname,然后添加项目即可

  7. 混合app

    cordova run android            把应用发送到手机   ionic serve        电脑浏览器调试命令   创建: cordova create hello co ...

  8. 【转】解决memcached启动失败

    原文:http://chenzhou123520.iteye.com/blog/1925196 linux上启动Memcache报错: 原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib* ...

  9. C# 取Visio模型信息的简易方法

    最近的一个项目,要求导出Visio图纸,因为是建筑类的,所以,需要设置墙壁,门,房间等信息的参数. 拿墙壁为例,选中墙壁模型,右键属性,会弹出以下对话框. 需要设置墙长.墙壁厚度等一些列信息. 现在C ...

  10. dubbo专题」dubbo其实很简单,就是一个远程服务调用的框架(1)

    一.dubbo是什么? 1)本质:一个Jar包,一个分布式框架,,一个远程服务调用的分布式框架. 既然是新手教学,肯定很多同学不明白什么是分布式和远程服务调用,为什么要分布式,为什么要远程调用.我简单 ...