G - Reduced ID Numbers(第二季水)
Description
Input
Output
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(第二季水)的更多相关文章
- B - Maya Calendar(第二季水)
Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old ...
- L - 辗转相除法(第二季水)
Description The least common multiple (LCM) of a set of positive integers is the smallest positive i ...
- poj 2769 Reduced ID Numbers(memset使用技巧)
Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...
- C - Reduced ID Numbers 寒假训练
T. Chur teaches various groups of students at university U. Every U-student has a unique Student Ide ...
- Y - Design T-Shirt(第二季水)
Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA ...
- 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 ...
- D - Counterfeit Dollar(第二季水)
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- S - 骨牌铺方格(第二季水)
Description 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种, ...
- R - 一只小蜜蜂...(第二季水)
Description 有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行.请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数. 其中,蜂房的结构如下所示. ...
随机推荐
- 漂亮回答面试官struts2的原理
众所周知,Struts2是个非常优秀的开源框架,我们能用Struts2框架进行开发,同时能快速搭建好一个Struts2框架,但我们是否能把Struts2框架的工作原理用语言表达清楚,你表达的原理不需要 ...
- 从汇编看c++中的placement operator new
placement operator new是重载的operator new运算符,它允许我们将对象放到一个指定的内存中.下面来看c++源码: class X { private: int _x; p ...
- Hello Word!
第一次来博客园,作为技术的基站,多余的话不说了,就一个helloword! <script type="text/javascript"> //等待dom元素加载完毕. ...
- 浅谈localStorage本地存储
在年会的抽奖程序中用到了localStorage现在拿出来总结下,localStorage的相关用法. 在年会抽奖的程序中,需要把获奖名单存储下来,年会现场没有网络,能最简单实现数据存储的方式就是,将 ...
- mysql----show slave status \G 说明
show slave status \G 可以用来查看mysql 的复制状态,有些列名所表达的意思不太明确,现整理如下: 1. Slave_IO_State:ID线程的状态,如果master 的所有变 ...
- JavaScript插件 Bootstrap自带了13个jQuery插件,这些插件为Bootstrap中的组件赋予了“生命”
原文:http://v2.bootcss.com/javascript.html#popovers
- 给FPGA初学者的建议——不要浮躁(转)
原作者:http://hi.baidu.com/zhoubin7020 作为FPGA新人常常在论坛上问,用什么语言啊,用什么软件啊,用那个公司的芯片等问题.我个人认为学习FPGA和学习单片机有相同的道 ...
- python学习资料
http://woodpecker.org.cn/diveintopython/ http://www.cnblogs.com/txw1958/archive/2012/12/10/A_Byte_of ...
- UFI命令格式里SCSI指令
有三种字长命令:6位.10位.12位,一般Windows下用12位. 在UFI 命令格式里SCSI指令用到如下: 指令代码 指令名称 说明 04h Format Unit 格式化存储单元 12h In ...
- ListView与CheckBox组合实现单选
main.xml配置文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...