Reduced ID numbers (Key use of memset)

Source: Internet
Author: User

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 CED 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

211248663124866111111987651

Sample output

18. modulo the same number of M values for the given groups of data. The remainder is different .....
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> using namespace STD; const int maxn = 1000000 + 5; int A [305]; int B [maxn]; int main () {int N, I; CIN> N; while (n --) {int t; CIN> T; for (I = 0; I <t; I ++) scanf ("% d", & A [I]); If (t = 1) printf ("1 \ n"); else {for (I = 2; I ++) {bool flag = 0; memset (B, 0, sizeof (INT) * (I + 1); // key use; otherwise, TLE will die... For (Int J = 0; j <t; j ++) {B [A [J] % I] ++; if (B [A [J] % I] = 2) {flag = 1; break ;}} if (flag = 0) break ;} cout <I <Endl ;}} return 0 ;}

 

Reduced ID numbers (Key use of memset)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.