AtCoder Beginner Contest 308 C题 Standings

【解题总结】Atcoder Beginner Contest 汇总 ABC 阅读详情

C题:Standings

标签:结构体排序、精度

题意:给定 n n n人扔硬币,第 i i i个人扔硬币,有正面朝上 A i A_i Ai​次和反面朝上 B i B_i Bi​次。定义成功率为 A i A i + B i A_i\over A_i+B_i Ai​+Bi​Ai​​。求按成功率从高到低,成功率相同根据编号从小到大排序。

题解:先把每个人的编号 i d id id按输入顺序设置好,然后根据题目中成功率和编号的要求排序就好了。这道题有个坑点就是,直接用 d o u b l e double double除出来会有精度缺失,所以我们把除法运算转成乘法运算。如果有两个人 x x x和 y y y,那我们把不等式的分母乘到对面去得到 ( x . a + x . b ) ∗ y . a < ( y . a + y . b ) ∗ x . a (x.a + x.b) * y.a < (y.a + y.b) * x.a (x.a+x.b)∗y.a<(y.a+y.b)∗x.a。

代码:

#include <bits/stdc++.h>
using namespace std;
 
struct node {
    int id;
    long long a, b;
}p[2000005];
 
bool cmp(node x, node y) {
    if ((x.a + x.b) * y.a == (y.a + y.b) * x.a) return x.id < y.id;
    else return (x.a + x.b) * y.a < (y.a + y.b) * x.a;
}
 
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i].a >> p[i].b;
        p[i].id = i;
    }
    sort(p + 1, p + 1 + n, cmp);
    for (int i = 1; i <= n; i++) {
        cout << p[i].id << " ";
    }
    return 0;
}
OJ题目-----Standings 题目描述 solo发现他参加Online Judge的比赛表现很不稳定,于是他翻开历史记录,发现他在每一轮的比赛中他的排名R都能被参赛人数N(包括solo,0<N<10^9)整除,于是他每次参赛都会先预测他的排名情况,以给自己更大的自信。 思路 显然,这个题目实质上就是求解一个数N的所有因数的问题,所以我们首先会想到下面的方法: ArrayList<In... 阅读详情

相关推荐

使用IntelliJ IDEA配置版本管理(SVN和Git)

在开发过程中,版本管理是必不可少的一部分,它可以帮助团队协作、管理代码历史记录,并且提供了代码回滚和分支管理等功能。本文将介绍如何使用IntelliJ IDEA配置版本管理,包括SVN和Git两种方式,另外列举了常见的问题并指导修复,以帮助开发者更高效地进行代码管理和协作。

2868

AtCoder Beginner Contest 308 A-F题解

AtCoder Beginner Contest 308 A-F题解

超哥聊信奥 1033

HA集群 执行 hdfs haadmin -transitionToActive 失败

最近把一个单NameNode集群变更为HA集群,过程中都很顺利,nn1和nn2两个NameNode都显示standby状态,但是把nn1或者nn2切换到active状态时就会报错抛异常。 查看master上namenode启动日志,如下: Incompatible clusterID for journal Storage Directory /home/hadoop-zero/bigdat...

qq_34727158的博客 1763

[abc周赛复盘] AtCoder Beginner Contest 308 20230701

T1 模拟T2 单源最短路dijikstraT3 多源最短路floyd。

liuliangcan的博客 651

Maya vray 3S皮肤材质球设置与材质节点连接

Maya vray 3S皮肤材质球设置与材质节点连接

WETQETF的博客 2697

Xilinx Chip2Chip IP核实战:Aurora PHY通信配置与仿真避坑指南

本文深入解析Xilinx Chip2Chip IP核与Aurora PHY的通信配置与仿真优化,提供实战避坑指南。通过AXI协议转换桥实现FPGA间高速数据传输,详细讲解Aurora PHY参数设置、仿真加速技巧及常见问题解决方案,帮助工程师快速部署稳定高效的芯片间通信系统。

g5h6i7j的博客 1005

AtCoder Regular Contest 080 D - Grid Coloring

地址:http://arc080.contest.atcoder.jp/tasks/arc080_b 题目: D - Grid Coloring Time limit: 2sec /Memory limit: 256MB Score :400points Problem Statement We have a grid withHrows andWcolu...

weixin_30646505的博客 211

机器学习实战7-基于机器学习算法预测相亲成功率

大家好,我是微学AI,今天给大家介绍一下机器学习实战7-基于机器学习算法预测相亲成功率,随着社会的发展,大家都忙于事业,对自己的终身大事就耽搁了,相亲是一种传统的寻找伴侣的方式,随着时代的发展,相亲的方式也在不断地改变。在这个过程中,了解相亲双方的信息以及预测相亲是否成功变得越来越重要。本文将介绍如何使用随机森林算法对相亲成功进行预测,通过分析男女双方的房子、车子、长相、家庭条件、父母情况、生活习惯、学历、性格、兴趣等因素,来预测相亲是否成功。

微学AI的博客 3030

AtCoder Beginner Contest 308

令flag=1,如果在1到8个数中有数不符合3个条件中的一个使flag=0。再最后判断flag是否为1,为1输出Yes,否则输出No。高桥吃了n盘寿司,不同颜色的盘子Ci对应不同的价格,颜色Di对应的价格为Pi,i>1,如果颜色Ci未在Di中出现则价格为P0。从D1开始找直到Dm,或者找到为止,如果找到了总价加上Pi,如果没找到加上P0。满足输出Yes,不满足输出No。求8个整数组成的序列是否满足。2.在100到675之间。

jiaking_two的博客 447

基于Flink的流式数据降维实现方案

理解为何实时场景需要降维(解决维度灾难)掌握Flink流处理与降维算法的结合方式学会用Flink实现一个可落地的流式降维系统覆盖内容包括:Flink流处理基础、降维算法选择(侧重在线算法)、Flink与降维的集成方案、实战代码示例,以及工业级场景的应用经验。本文从“为什么需要流式降维”出发,用“快递分拣”的生活案例引出核心概念;接着拆解Flink流处理、数据降维的底层逻辑;然后重点讲解“在线PCA”这一适合流式场景的降维算法,并用Flink实现一个完整的流式降维管道;

AI 领航者的博客 565

【ArcGIS遇上Python】批量提取多波段影像至单个波段

本案例基于ArcGIS python,将landsat影像的7个波段影像数据,批量提取至单个波段。

智慧空间实验室 2072

Mex Game【Atcoder】

而最终决定胜负的也就是mex(X)这一个元素,我们此时已不用考虑它定义中的最大最小,因为只剩下了一个元素,就是mex(X)。那么这个博弈的胜方便很明了了,若是字符串中A比B多,则Alice胜,B比A多则Bob胜,一样多则Alice胜,因为她先手。如果t是奇数,则Alice将选择一个非负整数x,并将X替换为X∪{x};如果t是偶数,Bob将选择一个非负整数x,并将X替换为X∪{x}。对于由非负整数组成的有限集合X,mex(X)是使得x∉X的最小非负整数x。你得到一个长度为 N+1N+1 的字符串,由。

RaedQm的博客 570

危废焚烧优化控制系统设计与实现:基于数据驱动的控制参数预测

本文提出了一种基于数据驱动的危险废物焚烧过程优化控制方法。系统利用历史运行数据和实时监测数据,通过深度学习模型预测关键控制参数,实现焚烧过程的智能化控制。系统采用Python开发,结合TensorFlow/PyTorch框架,构建了完整的数据采集、预处理、特征工程、模型训练和实时预测闭环系统。该系统能够处理多变量非线性关系,适应工况变化,从历史数据中学习最优控制策略,相比传统PID控制方法具有显著优势。论文详细介绍了系统架构、算法设计和实现细节,为危废焚烧过程的优化控制提供了有效解决方案。

huanghm88的专栏 206

【每日一题】——C - Standings(AtCoder Beginner Contest 308 )

C - Standings(AtCoder Beginner Contest 308 )

PH_modest的博客 470

深度学习工具包 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")

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

(题解包会篇)AtCoder-abc128-b Guidebook

​ Hello大家我又来分享题目咯,本题是来自AtCoder的一道题,具体题目在链接:B - Guidebook ​

2301_80568946的博客 554

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Atcoder Beginner Contest 308

会卡精度,double就不能过全部数据,改成long double就AC了。对比之后发现我的代码少了标记已经走过的点。

m0_74087709的博客 384

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

AtCoder 330. E Mex and Update (关于Mex的总结 + TreeSet和优先队列的性能问题

ATCoder 330 E

weixin_73227648的博客 487

AtCoder - abc194_e Mex Min

题目:AtCoder - abc194_e 题意:我们要找到长度为 n 数组 A 的所有的长度为 m 的切片 si 最小的 mex(si) 值。 思路: 可以发现,如果记录切片中每一个数字出现的次数,找到第一个出现次数为0的就是答案。 但是我们不能每次切片改变都去遍历一次,这样会TLE,因此可以用一个数组M维护区间(i,i+m)数字出现的次数。 切片的末尾指向了 Ai 的时候,那么对应的 Ma[i]M_{a[i]}Ma[i]​就会加1;而Ma[i−m]M_{a[i-m]}Ma[i−m]​ 就会减1。 接下

buzzaz的博客 627

AtCoder Beginner Contest 308(A-E)

【代码】AtCoder Beginner Contest 308(A-E)

qq_64177153的博客 192

零点工作室暑假集训(AtCoder--ABC308)

题意:有C[N]个寿司和D[M]个盘子,价格从P[0]~~P[M],分别由颜色,找出是否有寿司和盘子颜色一样,一样的话价格对应D[i]--P[i];不一样的话价格都为P[0].求出这些寿司的价格。思路:一开始想到用暴力去做,还以为看错题目wa了三次,导致很晚才写完B,正常暴力解法超过n,m超过1e5就过不了了,还可以用map做时间复杂度O(n)。暂时还没写出来,等写出来再补上。

weixin_73807663的博客 528

AtCoder Beginner Contest 165 C Many Requirements 深搜dfs+生成非递减数组

AtCoder Beginner Contest 165 比赛人数11730 比赛开始后15分钟看到所有题 AtCoder Beginner Contest 165 C Many Requirements 深搜dfs+生成非递减数组 总目录详见https://blog.youkuaiyun.com/mrcrack/article/details/104454762 在线测评地址https:...

mrcrack的博客 558

AtCoder Beginner Contest 272 E - Add and Mex(调和级数) (神智不清的一周)

AtCoder Beginner Contest 272 E - Add and Mex(调和级数) (神智不清的一周) 调和级数

qq_45377553的博客 529

AtCoder Beginner Contest 308 题解(C~F)

考虑贪心的策略,即是先选价值较大的还是选价值较小的,容易发现从价值较小的物品选起是正确的,因为后面价值较大的物品不会影响前面的物品,因为优惠劵有限制。因此我们只需对物品按价值从小到大排序,然后对优惠券也排个序,满足条件的优惠券都插入到优先队列中去,然后每次取堆顶的优惠券来计算答案即可。,我们考虑中间字符“E” ,对于每个字符“E” ,我们只要统计它前面有几个“M”,以及它后面有几个“X”,然后计算一下贡献即可。题意:给定字符串,只包括"M",“E”,“X”,其值为。的物品才能使用,然后优惠。

weixin_63785821的博客 408

AtCoder题解 —— AtCoder Beginner Contest 188 —— C - ABC Tournament —— 数据结构之二叉树

题目相关 题目链接 AtCoder Beginner Contest 188 C 题,https://atcoder.jp/contests/abc188/tasks/abc188_c。 Problem Statement 2N2^N2N players, labeled 111 through 2N2^N2N, will compete against each other in a single-elimination programming tournament. The rating of Play

努力中的老周的专栏 854

AtCoder Beginner Contest 308 B题 Default Price

AtCoder Beginner Contest 308 B题 Default Price

超哥聊信奥 1332

ABC308 A-G题解

孩子不懂事瞎写的题解,看着图个乐就好

Muelsyse_的博客 795
上一篇: AtCoder Beginner Contest 308 A题 New Scheme
下一篇: AtCoder Beginner Contest 308 B题 Default Price
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值