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 = 10 6-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

没看懂题意 该题是求 各组数据取余不同 的最小数字
#include<iostream>
using namespace std;
int cmp ( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
void f(int s[],int n)
{
int k,t,a[];
bool flag;
for(t=;;t++){
flag=true;
for(int i=;i<n;i++){
a[i]=s[i]%t;
}
qsort(a,n,sizeof(a[]),cmp);
for(int i=;i<n-;i++)
if(a[i]==a[i+]){
flag=false;
break;
}
if(flag==true)break;
}
cout<<t<<endl;
}
int main()
{
int n;
cin>>n;
while(n--){
int g,s[];
cin>>g;
for(int i=;i<g;i++)cin>>s[i];
if(g==)cout<<<<endl;
else f(s,g);
}
//system("pause");
return ;
}

G - Reduced ID Numbers(第二季水)的更多相关文章

  1. B - Maya Calendar(第二季水)

    Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...

  2. L - 辗转相除法(第二季水)

    Description The least common multiple (LCM) of a set of positive integers is the smallest positive i ...

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

    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. Y - Design T-Shirt(第二季水)

    Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...

  6. F - The Fun Number System(第二季水)

    Description In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight o ...

  7. D - Counterfeit Dollar(第二季水)

    Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...

  8. S - 骨牌铺方格(第二季水)

    Description          在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.         例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...

  9. R - 一只小蜜蜂...(第二季水)

    Description          有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数.         其中,蜂房的结构如下所示.     ...

随机推荐

  1. ios禁用多按钮同时点下的效果

    只需要把那些不能同时点下的按钮或者视图设置一下即可. [view setExclusiveTouch:YES]; 避免view上多个button同时按下,则可设置每个button的setExclusi ...

  2. 使用Unity在MVC上实现动态注入

    一.前言 通过前一篇的文章介绍使用unity轻量级的依赖注入容器,本文就介绍在MVC上使用unity依赖注入控制器和控制器中的日志属性. 实现MVC中新提供 的两个接口:IDependencyReso ...

  3. Webfrom基础知识

    MyBeNASP.NET内置对象 (1)简述ASP.NET内置对象. 答:ASP.NET提供了内置对象有Page.Request.Response.Application.Session.Server ...

  4. Ubuntu14.04配置arm-linux-gcc 4.4.3交叉编译环境

    首先下载交叉编译:不多说,直接贴地址了 http://arm9download.cncncn.com/mini2440/linux/arm-linux-gcc-4.4.3-20100728.tar.g ...

  5. 安装setuptools和pip

    什么是setuptool和pip python的强大在于它有许许多多的包,当我们要用到这些包时,一个一个的从官网下载安装就太麻烦了,setuptools和pip就提供了下载安装第三方包的功能.pip是 ...

  6. yii2 去掉index.php的方法

    1.开启apache-rewrite 在Windows下,我们一般使用的是Administrator账号,所以启用这两项非常简单: 在[Apache安装目录]/conf/httpd.conf中找到 # ...

  7. 让操作javascript对象数组像.net lamda表达式一样

    让操作javascript对象数组像.net lamda表达式一样 随着web应用程序的富客户端化.ajax的广泛使用及复杂的前端业务逻辑.对js对象数组.json数组的各种操作越来越多.越来越复杂. ...

  8. linux的一点一滴---open

    open函数用于打开和创建一个文件. 所需头文件: #include<sys/types.h> #include <sys/stat.h> #include <fcntl ...

  9. socket浅谈

    1什么是socket? socket的英文原义是“孔”或“插座”.作为进程通信机制,取后一种意思. 通常也称作“套接字”,用于描述IP地址和端口,是一个通信链的句柄. (其实就是两个程序通信用的.)是 ...

  10. 客户端HttpClient处理 Servlet Gzip

    服务端采用gzip对文本内容进行压缩处理,客户端使用HttpClient获取数据并进行gzip解压缩. 一: 服务端 public class GzipTestServlet extends Http ...