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. vs2010中出现:程序管理器匹配不正确错误

    http://bbs.csdn.net/topics/360074795 这是一篇csdn上的讨论帖,第15楼给出了正解

  2. javascript事件捕获与冒泡

    对“捕获”和“冒泡”这两个概念,我想我们对冒泡更熟悉一些,因为在我们使用的所有浏览器中,都支持事件冒泡,即事件由子元素向祖先元素传播的,就 像气泡从水底向水面上浮一样.而在像firefox,chrom ...

  3. 异常处理与调试6 - 零基础入门学习Delphi55(完)

    调试(Debug) 让编程改变世界 Change the world by program 使用调试窗口 为方便调式程序,Delphi中提供了许多调试窗口,给开发人员的调试工作带来了极大的便利. 断点 ...

  4. Html 编码 queryUrl = encodeURI(queryUrl);

    Html  编码 queryUrl = encodeURI(queryUrl);

  5. SED&AWK

    SED   1.sed是流编辑器(stream editor)缩写,作用主要是文本替换 命令格式:sed ‘s/pattern/replace_string/' file或者cat file | se ...

  6. wordpress教程之自带缩略图功能

    首页你要看下你所用的主题有没有开启文章缩略图功能,如果看起的话,会在wordpress后台编辑页面或者文章时在右下角的地方看到一个特色图像的设置,如下图: 如果没有说明你还没有激活这功能.我们需要在你 ...

  7. Mysql基本类型(字符串类型)——mysql之二

    转自: http://www.cnblogs.com/doit8791/archive/2012/05/28/2522556.html 1.varchar类型的变化 MySQL 数据库的varchar ...

  8. Linux安装开发环境,必须配置的环节(Fedora15版本)

    前提:U盘安装fedora:<[原]U盘安装Fedora15 DVD镜像>.<Grub引导安装Fedora15>   1.设置代理上网:<fedora 配置网络代理> ...

  9. windows bat脚本编写

    windows批处理 (cmd/bat) 编程详解 开始之前先简单说明下cmd文件和bat文件的区别:在本质上两者没有区别,都是简单的文本编码方式,都可以用记事本创建.编辑和查看.两者所用的命令行代码 ...

  10. JDBC的使用——Statement

    JDBC是Java最基本的数据库操作途径,虽然现在有了更高端的Hibernate和JPA,但是其实它们的底层还是用的这些最基本的JDBC.而且,如果开发一个小型的应用程序,使用Hibernate不免有 ...