poj 2769 Reduced ID Numbers(memset使用技巧)
Description
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
one SIN. The SINs within a group are distinct, though not necessarily sorted.
Output
Sample Input
2
1
124866
3
124866
111111
987651
Sample Output
1
8
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int t[310];
bool vis[1000010]; int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m,i,j;
scanf("%d",&m);
for(i=1;i<=m;i++)
cin>>t[i];
for(i=m;;i++)
{
memset(vis,false,i*sizeof(vis[0])); //时间172ms
for(j=1;j<=m;j++) //memset(vis,false,sizeof(vis)); tle
if(vis[t[j]%i]) break;
else vis[t[j]%i]=true;
if(j>m) break;
}
printf("%d\n",i);
}
return 0;
}
poj 2769 Reduced ID Numbers(memset使用技巧)的更多相关文章
- poj 2769 Reduced ID Numbers 同余定理
链接:http://poj.org/problem?id=2769 题意:寻找数m,是的对于n个数的余数不同 思路:暴力,优化:同余部分不用测试 代码: #include <iostream&g ...
- C - Reduced ID Numbers 寒假训练
T. Chur teaches various groups of students at university U. Every U-student has a unique Student Ide ...
- G - Reduced ID Numbers(第二季水)
Description T. Chur teaches various groups of students at university U. Every U-student has a unique ...
- poj 1651 http://poj.org/problem?id=1651
http://poj.org/problem?id=1651Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K To ...
- poj 1679 http://poj.org/problem?id=1679
http://poj.org/problem?id=1679 The Unique MST Time Limit: 1000MS Memory Limit: 10000K Total Submis ...
- POJ3278http://poj.org/problem?id=3278
http://poj.org/problem?id=3278 题目大意: m,n两个数m可+1, -1, *2变成n,需要经过几步 #include<stdio.h> #include&l ...
- POJ 3252:Round Numbers
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...
- POJ 2769
http://poj.org/problem?id=2796 题意:求n个数的和乘以这n个数中的最小值的积最大的数,以及其范围. 思路:求每一个数两边的比其大的数的和,再乘以这个数.还有一个范围,用单 ...
- poj-3056 http://poj.org/problem?id=3056
http://poj.org/problem?id=3056 The Bavarian Beer Party Time Limit: 6000MS Memory Limit: 65536K Tot ...
随机推荐
- <转载>Div+Css布局教程(-)CSS必备知识
目录: 1.Div+Css布局教程(-)CSS必备知识 注:本教程要求对html和css有基础了解. 一.CSS布局属性 Width:设置对象的宽度(width:45px). Height:设置对象的 ...
- Windows Azure入门教学系列 (六):使用Table Storage
本文是Windows Azure入门教学的第六篇文章. 本文将会介绍如何使用Table Storage.Table Storage提供给我们一个云端的表格结构.我们可以把他想象为XML文件或者是一个轻 ...
- <input type=button> 跳转页面
打开新页面 标题" type="button" onclick='window.open("bedzhao.aspx")' /> 转换本页面 标 ...
- ajax提交整个form表单
在项目开发中,有时提交form表单时不能单单用action或者jquery的 表单提交方法有三种,主要说下第三种 第一种:用form自带属性action提交 第二种:用jquery提交:$(" ...
- UVA 10201 Adventures in Moving - Part IV(dp)
Problem A: Adventures in Moving - Part IV To help you move from Waterloo to the big city, you are co ...
- poj2531
看了一下0ms,16ms,100ms左右过了的代码,思维量对我来说比較大,不是非常easy理解. 我的作法: 用并查集算权值和. 用dfs枚举两个点集的全部可能,因为是全然图,枚举一半的点就可以. # ...
- JavaScript-4.6鼠标事件监听,获取鼠标坐标window.event---ShinePans
<html> <head> <meta http-equiv="content-type" content="text/html" ...
- Cocos2d-x 学习(1)—— 通过Cocos Studio创建第一个Demo
近期在工作上有了比較大的转变,自学情绪也慢慢高涨,本来一直在研究unity的技术.由于换了工作会開始接触cocos2d-x.但并不意味着停止研究unity,以后有时间还是会继续的. 公司的cocos2 ...
- 单元测试工具 SmokeTest
.NET 程序集单元测试工具 SmokeTest Smoke Test(冒烟测试),也称Regression Test(回归测试),是对软件的安装和基本功能的测试.一般地我们使用脚本来实现Smoke ...
- asp.net web api帮助文档的说明
为asp.net的mvc web api填写自己的帮助文档 1. 加入Help的area(能够通过命令行或其它方式加入) 命令行:Install-Package Microsoft.AspNet.We ...