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的可能路线数. 其中,蜂房的结构如下所示. ...
随机推荐
- ios禁用多按钮同时点下的效果
只需要把那些不能同时点下的按钮或者视图设置一下即可. [view setExclusiveTouch:YES]; 避免view上多个button同时按下,则可设置每个button的setExclusi ...
- 使用Unity在MVC上实现动态注入
一.前言 通过前一篇的文章介绍使用unity轻量级的依赖注入容器,本文就介绍在MVC上使用unity依赖注入控制器和控制器中的日志属性. 实现MVC中新提供 的两个接口:IDependencyReso ...
- Webfrom基础知识
MyBeNASP.NET内置对象 (1)简述ASP.NET内置对象. 答:ASP.NET提供了内置对象有Page.Request.Response.Application.Session.Server ...
- Ubuntu14.04配置arm-linux-gcc 4.4.3交叉编译环境
首先下载交叉编译:不多说,直接贴地址了 http://arm9download.cncncn.com/mini2440/linux/arm-linux-gcc-4.4.3-20100728.tar.g ...
- 安装setuptools和pip
什么是setuptool和pip python的强大在于它有许许多多的包,当我们要用到这些包时,一个一个的从官网下载安装就太麻烦了,setuptools和pip就提供了下载安装第三方包的功能.pip是 ...
- yii2 去掉index.php的方法
1.开启apache-rewrite 在Windows下,我们一般使用的是Administrator账号,所以启用这两项非常简单: 在[Apache安装目录]/conf/httpd.conf中找到 # ...
- 让操作javascript对象数组像.net lamda表达式一样
让操作javascript对象数组像.net lamda表达式一样 随着web应用程序的富客户端化.ajax的广泛使用及复杂的前端业务逻辑.对js对象数组.json数组的各种操作越来越多.越来越复杂. ...
- linux的一点一滴---open
open函数用于打开和创建一个文件. 所需头文件: #include<sys/types.h> #include <sys/stat.h> #include <fcntl ...
- socket浅谈
1什么是socket? socket的英文原义是“孔”或“插座”.作为进程通信机制,取后一种意思. 通常也称作“套接字”,用于描述IP地址和端口,是一个通信链的句柄. (其实就是两个程序通信用的.)是 ...
- 客户端HttpClient处理 Servlet Gzip
服务端采用gzip对文本内容进行压缩处理,客户端使用HttpClient获取数据并进行gzip解压缩. 一: 服务端 public class GzipTestServlet extends Http ...