poj-2769-Reduced ID Numbers
2016-07-25 14:37
387 查看
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
题目的意思是:给一系列个数,要你求一个数,然后使他们的mod都不一样
数据范围也没有多大,直接暴力去算即可
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
题目的意思是:给一系列个数,要你求一个数,然后使他们的mod都不一样
数据范围也没有多大,直接暴力去算即可
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; const int maxn=1000001; int a[maxn]; bool vis[maxn]; int main() { int t; scanf("%d",&t); while(t--) { int n; int ans=0; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); bool flag; for(int i=1;i<maxn;i++) { flag=true; for(int z=0;z<=i;z++) vis[z]=0; for(int j=0;j<n;j++) { if(vis[a[j]%i]) { flag=false; break; } vis[a[j]%i]=1; //printf("111\n"); } if(flag) { ans=i; break;} } printf("%d\n",ans); } return 0; }
相关文章推荐
- 音乐播放时跳动的音符
- [20160725]ArithmeticTest
- springboot与shiro配置
- 蘑菇街笔试题总结
- 通过samba共享目录的方式搭建lamp平台并安装wordpress(二)
- Android-原生系统分享小记
- 遇到的兼容性能问题
- 安卓开发参考资料
- 弱鸡的暑假图论安排
- 微信分享透明背景图片背景变黑
- dubbo 入门教程 基于zookeeper
- ap
- java读取properties文件的方法
- 设计模式--原型模式
- fatal error C1060:compiler is out of heap space
- titanic survival 1
- Retrofit2简单使用初试用
- Android Studio导入Project、Module的正确方法
- 定时任务 中的job中注入的service接口 为空 解决方法
- document.body.scrollTop用法