POJ 3640 Conformity(Hash)

『杭电1904』Conformity Submit 阅读详情

Description

Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire to take various combinations of courses from among those available.

University administrators are uncomfortable with this situation, and therefore wish to offer a conformity prize to frosh who choose one of the most popular combinations of courses. How many frosh will win the prize?

Input

The input consists of several test cases followed by a line containing 0. Each test case begins with an integer 1 ≤ n ≤ 10000, the number of frosh. For each frosh, a line follows containing the course numbers of five distinct courses selected by the frosh. Each course number is an integer between 100 and 499.

The popularity of a combination is the number of frosh selecting exactly the same combination of courses. A combination of courses is considered most popular if no other combination has higher popularity.

Output

For each line of input, you should output a single line giving the total number of students taking some combination of courses that is most popular.

Sample Input

3
100 101 102 103 488
100 200 300 101 102
103 102 101 488 100
3
200 202 204 206 208
123 234 345 456 321
100 200 300 400 444
0

Sample Output

2
3

【题意】n个学生,每人5门课程代号(100~499)的组合,定义这些课程组合的重复次数为受欢迎度。问选受欢迎度最大的课程组合的学生人数是多少。
【解题思路】

将每个学生所选的5门课进行从小到大排序,拼起来组成一个15位的数。由于变换之后的数太大,所以要哈希一下在存储。接下来再判重即可。使用的是最常见的线性探测,大整数求余hash的方法。

【AC代码】

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define CLE(a,b) memset(a,b,sizeof(a))
#define MEC(a,b) memcpy(a,b,sizeof(a))
#define ll long long
const int ll mod = 100007;
ll Hash[mod],pos[mod],top[mod],x[mod];
int n;
int get_Hash(ll num)
{
    int tmp = (num%mod+mod)%mod;
    while(Hash[tmp]!=-1&&Hash[tmp]!=num)tmp = (tmp+1)%mod;
    return tmp;
}
int main()
{
    while(~scanf("%d",&n)&&n)
    {
        ll ans = 0;
        CLE(top,0);CLE(Hash,-1);
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<5; j++)
            {
                scanf("%I64d",&x[j]);
            }
            sort(x,x+5);
            ll tmp = 0;
            for(int j=0; j<5; j++)
            {
                tmp = tmp*1000+x[j];
            }
            int in = get_Hash(tmp);
            Hash[in] = tmp;
            ans = max(ans,++top[pos[i]=in]);
        }
//        cout<<ans<<endl;
        int sum = 0;
        for(int j=0; j<n; j++)
        {
            if(top[pos[j]]==ans)sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}



airodump-ng、aircrack-ng使用教程 wifi破解、airodump-ng、aircrack-ng脚本 阅读详情

相关推荐

从零构建MAVLink通信:PX4飞控与QGC的协议握手全解析

本文详细解析了PX4飞控与QGC地面站通过MAVLink协议进行通信的全过程,重点介绍了航点传输协议的状态机设计、INT类型消息的优化优势以及异常处理与调试技巧。通过实战案例和性能优化建议,帮助开发者高效构建无人机通信系统,提升数据传输效率与稳定性。

weixin_29209805的博客 504

【hash】Conformity

Conformity Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2559   Accepted: 785 Description Frosh commencing their studies at Waterloo have diverse int

Ted's 游乐园 791

深入解析Android14应用安装权限:从声明到授予的完整适配指南

本文深入解析Android14应用安装权限的适配方法,重点介绍了从权限声明到授予的完整流程。与Android13相比,Android14在权限管理机制上进行了重要调整,特别是通过AppOpsManager实现权限的对象化封装。文章详细讲解了权限声明的基础配置、Framework层适配方案、运行时权限授予方法以及常见问题排查指南,帮助开发者高效完成Android14权限适配。

o9p0q1的博客 693

POJ 3640 Conformity

题意:n个学生,每人5门课程代号(100~499)的组合,定义这些课程组合的重复次数为受欢迎度。问选受欢迎度最大的课程组合的学生人数是多少。 题解:将每个学生所选的5门课进行从小到大排序,拼起来组成一个15位的数。即: for(int j=0;j<5;j++) temp=temp*1000+x[j]; 由于变换之后的数太大,所以要哈...

weixin_30335353的博客 299

日前日内多阶段多时间尺度源荷储协调调度(matlab代码)

多阶段多时间尺度的协调调度的优势是考虑新能源出力的波 动性与随机性,需求响应负荷的不确定性会对电网制定的日前调度计划准确性造成影响,也就是能够更加精准的进行调度和分析,优化结果的可用性更强。在这方面论文里面,金力的《考虑特性分布的储能电站接入的电网多时间尺度源储荷协调调度策略》就考虑了日前日内实时三个阶段调度,每个阶段考虑了不同负荷需求响应策略,同时考虑了负荷波动性的影响,具有很强的参考意义。 目录 一、模型 二、程序运行 三、程序链接 一、模型 负荷需求响应考虑电价型和激励型两种,电.

zhangxd212489的博客 7915

TC8:SOMEIPSRV_SD_MESSAGE_07-09

TTL为服务实例的生命周期。在此生命周期之后,不提供服务实例。

jasonj333 907

POJ3640 UVA11286 HDU1904 Conformity【map】

Conformity Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2981 Accepted: 908 Description Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire t...

海岛Blog 1160

基于STM32、HAL库的MICRF112YMM-TR 无线收发器驱动程序设计

内部集成了 VCO、PLL、PA、LNA、混频器、滤波器等射频功能单元,极大减少了外部元件数量,降低了设计和布线难度。: 具有多种工作模式(睡眠、待机、接收、发射),待机电流极低,非常适合电池供电的物联网(IoT)设备。是 Microchip 公司生产的一款高性能、低功耗的单片 UHF ASK/FSK 收发器芯片。: 支持 ASK (幅移键控) 和 FSK (频移键控) 调制,适应不同应用需求。// 可以添加其他配置参数,如中心频率、数据速率等。智能家居(安防、遥控、传感)远程钥匙进入系统 (RKE)

corlin6688的博客 414

POJ 3640 Conformity 可能会

woniupengpeng的专栏 424

24、企业治理、风险与合规:精益思维的应用与实践

本文探讨了如何运用精益思维优化企业治理、风险与合规(GRC)流程,分析了职责分离与合规流程的误区,提出了预防性与检测性控制措施的合理搭配,并通过价值流映射、减少合规反馈循环等方法实现流程优化。以Etsy的PCI-DSS实施为例,展示了如何在满足法规要求的同时保持创新活力。文章还强调了构建协作型GRC文化的重要性,并展望了未来GRC的发展趋势,包括数字化转型、全球化风险管理及与可持续发展的结合。

solidity8miner的博客 101

Unreal Engine开发:多人联机与网络同步_延迟补偿与预测

通过延迟补偿和预测技术,我们可以显著减少网络延迟对多人在线动作游戏的影响,提升玩家的体验。延迟补偿主要在服务器端实现,通过回溯时间点来更准确地处理输入和事件。预测技术主要在客户端实现,通过预先计算玩家的动作结果来减少延迟感。结合这两种技术,可以实现更平滑、更公平的多人游戏体验。

chenlz2007的博客 1191

【哈希】POJ 3640 Conformity

Conformity 解题思路 原来POJ用STL会T… 对每个组合,读进来之后先把 5 个数排序,拼成 15 位的数,之后去统计每个数出现的次数。 参考代码 #include<stdio.h> #include<iostream> #include<vector> #include<cstring> #include<cstdio> #include<climits> #include<cmath> #include&lt

Encore47的博客 306

198、影像系统设计评审流程:从需求评审到 EVT、DVT、PVT 各阶段的关注重点

本文详细介绍了影像系统从需求评审到EVT、DVT、PVT各阶段的设计评审流程及关键点。作者通过实际案例(如IMX766模组偏紫问题)强调硬件工艺的重要性,指出影像系统是功能定义与物理实现的反复拉锯过程。文章分阶段解析:需求评审需将模糊需求转化为物理参数;架构评审要明确接口定义和时序约束;EVT阶段重点关注模组一致性和基础链路;DVT阶段需平衡算法调优与硬件验证;PVT阶段则以量产一致性为核心。最后提出建立"边界条件确认表"和"健康度看板"等实用建议,强调工程师需具备从表象追溯硬件根源的物理直觉。全文贯穿实战

sundong_81的博客 216

POJ 3640 Conformity

题意:n个学生,每人5门课程代号(100~499)的组合,定义这些课程组合的重复次数为受欢迎度。问选受欢迎度最大的课程组合的学生人数是多少。   题解:将每个学生所选的5门课进行从小到大排序,拼起来组成一个15位的数。即:  for(int j=0;j                  temp=temp*1000+x[j];  由于变换之后的数太大,所以要哈希一下在存储。接下来再判重即

iCpC之旅 775

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

POJ 3640

题意:n个学生的5门课程,找出课程组合出现次数最多的,输出选出现次数最多课程组合(不一定一个)的学生人数。 题解:对5门课程排序,然后hash判重,接着统计即可。 View Code 1 #include<cstring> 2 #include<algorithm> 3 #include<string> 4 #include<ma...

weixin_30387339的博客 269

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ICPC训练联盟2021寒假冬令营(6)部分题解:

** ICPC训练联盟2021寒假冬令营(6)部分题解 ** 写好忘发了~~ A - The Blocks Problem Many areas of Computer Science use simple, abstract domains for both analytical and empirical studies. For example, an early AI study of planning and robotics (STRIPS) used a block world in whi

好好好,这么写博客是吧 692

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

ICPC训练联盟2021寒假冬令营(6)_2021.01.25_笔记

试题链接 点我进入代码提交OJ 学习笔记 - C++ STL 简介 • STL(Standard Template Library),也被称为标准模板库,包含大量的模板类和模板函数,是C++提供的一个由一些容器、算法和其他一些组件组成的集合。用于完成诸如输入/输出、数学计算等功能。 • STL被内置到支持C++的编译器中。在C++标准中,STL被组织为13个头文件:<iterator>,<functional>,<vector>,<deque>,<lis

qq_19403405的博客 1381

Conformity HDU - 1904

  把每行的5个数,升序排序然后将每个数字当成是一个字符,求这个5个数对应的hash值,然后求某种hash值出现最多的次数是多少,因为我把每行的那5个数的hash值都存入了mp里,所以遍历一遍mp,如果对应hash值出现次数等于最大次数就加否则不加,这样就可以求得选最受欢迎的课程的学生人数了 #include&lt;bits/stdc++.h&gt; using namespace std;...

SEIZE THE DAY 389

POJ 4014

ACM ICPC 2011–2012, NEERC, Northern Subregional Contest St Petersburg, October 29, 2011 Problem D. Dice Input file: dice.in Output file: dice.out Time limit: 3 seconds Memory limit: 256 m

mowenwen_的博客 1208

Sicily 1453. Conformity

1453. Conformity Constraints Time Limit: 2 secs, Memory Limit: 32 MB Description Frosh commencing their studies at Waterloo have diverse interests, as evidenced by their desire to take v

Nightonke's Blog 733

Spring_Hibernate_conformity

1.spring管理hibernate的事务:    ①在配置文件中加入以下配置   &lt;tx:annotation-driven transaction-manager="txManager"/&gt; &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionMan...

iteye_11956的博客 146
上一篇: Codeforences #345 C
下一篇: POJ 2002 Squares
just_sort
博客等级 码龄11年 2356粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值