# POJ 2769 Reduced ID Numbers [同余]【数论】

——————————-.
Reduced ID Numbers
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 9927 Accepted: 3960
Description

T. Chur teaches various groups of students at university U. Every U-student has a unique Student Identification Number (SIN). A SIN s is an integer in the range 0 ≤ s ≤ MaxSIN with MaxSIN = 106-1. T. Chur finds this range of SINs too large for identification within her groups. For each group, she wants to find the smallest positive integer m, such that within the group all SINs reduced modulo m are unique.
Input

On the first line of the input is a single positive integer N, telling the number of test cases (groups) to follow. Each case starts with one line containing the integer G (1 ≤ G ≤ 300): the number of students in the group. The following G lines each contain one SIN. The SINs within a group are distinct, though not necessarily sorted.
Output

For each test case, output one line containing the smallest modulus m, such that all SINs reduced modulo m are distinct.
Sample Input

2
1
124866
3
124866
111111
987651
Sample Output

1
8
Source

Northwestern Europe 2005

————————————–.

—————————————–。

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

/*********************INPUT*************************/
#define s2l(a,b)   scanf("%d%d",&a,&b)
#define s2_l(a,b)  scanf("%I64d%I64d",&a,&b)

/*********************OUTPUT*************************/
#define pr1l(a)    printf("%d",a);
#define pr1_l(a)   printf("%I64d",a);
#define pr1ll(a)   printf("%lld",a);
#define space      printf(" ");
#define line       printf("\n");

/****************************************/
#define _LL __int64
/****************************************/
#define fr(a,b,c)  for(int a=b;a<c;a++)
#define mem(a,b,c) for(int i=0;i<=c;i++)a[i]=b;
typedef long long int LL ;
#define INF 0x3f3f3f3f
#define pb push_back

#define lalal puts("*******");
/*************************************/

const int MOD = 1e9+7;
const int M = 1e5+10;

int a[M] , b[M];
int n;

bool check(int m)
{
memset(b , 0 , sizeof(b));
for(int i = 0 ; i < n ; i ++)
{
if(b[a[i] % m])
return false;
else
b[a[i] % m] = 1;
}
return true;
}

int main()
{

int _;
while(scanf("%d",&_)!=EOF)
while(_--)
{
scanf("%d",&n);
for(int i = 0 ; i < n ; i ++)
scanf("%d",&a[i]);

for(int m = 1 ; m < M ; m ++)
{
if(check(m))
{
printf("%d\n",m);
break;
}
}
}
return 0;
}


#### POJ 2769 Reduced ID Numbers (同余)

2015-04-21 21:00:41

#### POJ 2769 Reduced ID Numbers

2014-08-21 14:44:01

#### poj 2769 Reduced ID Numbers

2014-09-08 10:38:52

#### Reduced ID Numbers (memset 的关键用处）

2014-09-06 10:20:46

#### Poj 2769 Reduced ID Numbers

2014-03-12 16:37:08

#### Reduced ID Numbers(POJ 2769)

2014-08-22 15:37:07

#### poj 2769——Reduced ID Numbers

2014-06-21 02:02:39

#### POJ 2769 Reduced ID Numbers

2018-06-22 17:18:33

#### 2769 Reduced ID Numbers 同余问题

2013-07-25 20:23:17

#### Reduced ID Numbers （同余）

2016-11-08 19:31:25