CodeForces 492D Vanya and Computer Game

PointNetLK实战:5步搞定点云配准(附ModelNet40数据集训练技巧) 本文提供了一份详细的PointNetLK实战指南,帮助读者在5步内掌握点云配准技术。文章以ModelNet40数据集为例,深入讲解了环境搭建、数据预处理、模型训练与调试等核心步骤,并分享了关键的训练技巧和调参策略,旨在让开发者快速实现并应用这一高效的深度学习配准方法。 阅读详情
D. Vanya and Computer Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character spends fixed time to raise a weapon and then he hits (the time to raise the weapon is 1 / x seconds for the first character and 1 / y seconds for the second one). The i-th monster dies after he receives ai hits.

Vanya and Vova wonder who makes the last hit on each monster. If Vanya and Vova make the last hit at the same time, we assume that both of them have made the last hit.

Input

The first line contains three integers n,x,y (1 ≤ n ≤ 105, 1 ≤ x, y ≤ 106) — the number of monsters, the frequency of Vanya's and Vova's attack, correspondingly.

Next n lines contain integers ai (1 ≤ ai ≤ 109) — the number of hits needed do destroy thei-th monster.

Output

Print n lines. In the i-th line print word "Vanya", if the last hit on the i-th monster was performed by Vanya, "Vova", if Vova performed the last hit, or "Both", if both boys performed it at the same time.

Sample test(s)
input
4 3 2
1
2
3
4
output
Vanya
Vova
Vanya
Both
input
2 1 1
1
2
output
Both
Both
Note

In the first sample Vanya makes the first hit at time 1 / 3, Vova makes the second hit at time1 / 2, Vanya makes the third hit at time 2 / 3, and both boys make the fourth and fifth hit simultaneously at the time 1.

In the second sample Vanya and Vova make the first and second hit simultaneously at time1.

题目大意:n只怪兽有各自被攻击致死的次数,Vanya每秒攻击怪兽x次,Vova每秒攻击怪兽y次。求每只怪物被消灭时最后攻击它的是谁,如果同时攻击,输出Both。

解题思路:二分查找,时间作变量,以攻击次数为判断条件。可以理解为Vanya用y秒攻击一次,Vova用x秒攻击一次,Lcm(x,y)秒时同时攻击。mid秒时攻击了(mid/x+mid/y)次。

解题过程:wa点:注意用大数。

代码如下:

#include <cstdio>
#define LL long long
int main()
{
    LL n,x,y,t;
    LL high,low,mid,a;
    scanf("%lld%lld%lld",&n,&x,&y);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&t);
        high=1e15,low=0;
        while(low<=high)
        {
            mid=(high+low)/2;
            if(mid/x+mid/y<t)//mid时间里A的攻击次数+B的攻击次数与怪物被攻击致死的次数比较。
                low=mid+1;
            else
            {
                a=mid;	//记录下怪物刚好死亡的时间
                high=mid-1;
            }
        }
        if(a%x==0&&a%y==0)//a秒时A刚好击打,a秒时B刚好击打
             printf("Both\n");
        else if(a%y)   
            printf("Vova\n");
        else
            printf("Vanya\n");
    }
    return 0;
}


SAP 发货在途库存管理:POD确认差异下的2种后续调整方案对比 本文详细解析了SAP发货在途库存管理中POD确认差异后的财务调整方案,对比了移动类型417和555 T两种处理方式的适用场景及财务影响。通过实际案例说明如何优化POD流程,减少库存差异损失,提升供应链管理效率。特别适合SAP SD模块用户及供应链管理人员参考。 阅读详情

相关推荐

懒人精灵手游内存技术分析

教学声明:全套教程教学用到的游戏采用手游私服网游进行测试,不针对任何游戏。教学只做计算机技术研究,不做其他用途。

yizhihaoren123的博客 1655

数论 - Vanya and Computer Game

Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character p...

仓鼠 342

哨兵一号数据下载

哨兵1号数据的下载过程

weixin_59617499的博客 5134

D - Vanya and Computer Game

#include using namespace std; int main() {     long long int x,y,var;     long long int n,i;     cin>>n>>x>>y;     int v[x+y];     double a=1,b=1;     for(i=0; i     {         if(a*

u013570474的专栏 525

接上篇,记录一下【Unity 3D对博途PLCSIM的通讯】文章有点长~仔细看,很基础

本文参考链接:西门子PLC丨PROFINET通讯仿真(虚拟通讯)做了一些更详细的优化,本文使用的类库并非原作者使用的类库。 首先,昨天项目已经创建好了,这边也加了一个InputField和一个Button,可以实现简单的读取,ok开始。 放入准备好的通讯类库; 新建一个博途的项目,本次测试使用博途V15,测试环境为虚拟机,Unity运行在本地计算机,建立博途项目流程如下: 新建项目,右键项目-属性-保护-对勾,如图: 不得不说的是,仿真中加密的FB块是无法下载的哦~ 添加CPU...

NS_Speak(IVAV) 8055

HITS算法详解及代码实现

占坑

蓁蓁尔的博客 7461

492D - Vanya and Computer Game

D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a

Fourth Dimension 969

AI工程化之生成式UI & A2UI(一)

本文系统介绍了生成式UI和Google A2UI技术。生成式UI通过AI直接生成前端代码(完全生成式)或DSL(混合式),实现千人千面的动态界面和研发提效。Google A2UI提出组件级和消息级协议,采用JSON规范实现渲染框架解耦,支持多端渲染。文章详细阐述了A2UI的架构设计,包括协议生成、服务端处理和渲染器实现,并对比了与传统前端框架的差异,指出A2UI本质是UI=F(AI(UI)+AI(state))的创新模式。最后通过playground项目展示了A2UI的实践应用。

qq_34306228的博客 588

codeforces 492D. Vanya and Computer Game

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a computer game where th...

weixin_30471065的博客 144

stm32f103c8t6+esp8266在WiFi下通过手机控制外设

stm32f103c8t6+esp8266在WiFi下通过手机控制外设前言 前言 通过上一篇,介绍了esp8266的基本功能,这篇将用stm32c8t6配合esp8266进行数据交互,实现用手机通过无线的方式去控制外设、开关等;这里相当于把stm32作为上一篇的串口助手和esp8266进行通信; ...

weixin_45430735的博客 1万+

PTA-浙大版 《Python程序设计》 第三章编程题目及答案

博主第一次写优快云的博客,所以排版上可能有些不尽人意,代码部分均为自己的思路,可能复杂或者考虑欠妥,欢迎大家一起讨论~ 第一题:大于身高的平均值 这里用了np数组求得平均数,当然for循环累加也是可以的 import numpy as np data = input().split() data = list(map(int,data)) avg = np.mean(data) for i in data: if i > avg: print(i,end = '

Legendwqs的博客 1万+

Vanya and Computer Game

 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=89215 起初我是二分枚举第一个人的攻击次数发现有问题,意识到要二分枚举杀死怪兽的时间,那么问题来了如何处理每1/x秒攻击一次,因为二分边界和mid都是int型。由此想到做一个等价的变换如代码中的注释。 #include #include #include

思维迷宫 706

麒麟服务器操作系统QT系列软件工具手册

对Qt提供的开发工具进行了一系列的优化之后,在日常的修复bug和维护框架的过程中,桌面研发对Qt的基础软件库也进行了部分优化工作,包括qtbase、qtwayland、qtscript、qt4-x11等Qt基础组件,涉及的Qt框架版本主要涉及到5.9和5.12两个版本。qt 的翻译,是由 ts 文件生成 qm 文件然后进行翻译,国产操作系统上qt 的翻译是由单独的qttranslations包中进行维护,其次部分汉化问题也是qt组件维护工作的一部分,qt的翻译机制如图4-7所示。

太极淘的博客 542

Codeforces 492D Vanya and Computer Game

题目链接:Codeforces 492D Vanya and Computer Game 将两人的单位步长同时扩大相应倍数,使之均成为整数,然后处理出所有攻击时间,排序。 #include #include #include using namespace std; const int maxn = 2 * 1e6 + 5; const char sign[3][10] = {"Van

不慌不忙、不急不躁 925

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

CodeForces 492D Vanya and Computer Game(二分)

题意:Vanya每秒钟可以砍x刀,Vova每秒可以砍y刀,有n次询问,给你一个怪兽的血量为ai,然后问你最后一刀是谁补的刀,同时补刀,输出Both 思路:二分是多少s砍死这只怪兽,然后再check就好一下了 #include using namespace std; #define LL long long int main() { int n; LL x,y; scanf("%

围巾的ACM博客 638

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

codeforces 492D Vanya and Computer Game 数论

传送门:cf 492D 两只中二属性的"勇者",攻击频率分别为x,y,有n只怪物,两个人同时开始攻击,问谁能拿下 last attack 如果两者同时攻击时怪物死亡,则算他们同时拿下。问给定的n只怪物分别由谁拿下 last attack。 打表找规律,打出血量从1~x+y的时候分别由谁拿下的最后一击,然后取模输出就好 /************************************

飞火扑蛾的专栏 625

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

CodeForces - 492D Vanya and Computer Game 二分

CodeForces - 492D Vanya and Computer Game 二分 题意:Vanya和Vova打小怪兽。Vanya每秒可以攻击x次,Vova每秒可以攻击y次。怪兽可以承受m次攻击。求最后一刀是谁打的,同时打的输出Both。 题解:一个打一次1/x秒,另一个1/y秒。同乘x*y,也就可以看作一个打一次y秒,另一个x秒。二分出怪兽在第几秒死,然后看最后一刀是谁打的即可。

ACZone 299

【Codeforces 492D】Vanya and Computer Game

【链接】 我是链接,点我呀:) 【题意】 题意 【题解】 第一个人攻击一次需要1/x秒 第二个人攻击一次需要1/y秒 这两个数字显然都是小数。 我们可以二分最后用了多少时间来攻击。 显然这个是有单调性的,攻击时间越多的话,攻击的次数也就越多。 假设二分出来攻击的时间是mid 那么攻击的次数就是 mid/(1/x) + mid/(1/y) 但是这样显然二分出来的也是一个小数...

164

CodeForces 492D Vanya and Computer Game [二分]

有N只怪物,每只的血量为Ai,现在有两个人攻击力都为1,Vanya攻速为1秒X下,Vova攻速为每秒Y下,问每只怪物最后是被谁杀死的,如果一起打出最后一下,输出Both。

Asuna_acmer 606

【1】【二分搜索】CodeForces 492D Vanya and Computer Game

暑期集训

实现不可能 369

Codeforces 492D Vanya and Computer Game

题目链接:http://codeforces.com/problemset/problem/492/D 题意:游戏里,有2个玩家,a玩家1s内攻击x次,b玩家1s内攻击y次,给出若干个怪物的血量,问谁补得刀 思路:a玩家第i次攻击,b玩家第j次攻击,i/x > j/y(化简为i*y >j*x),i+j次是b的,若相等则i+j次攻击和i+j+1次攻击都视为同时攻击 #i

csdn364988181的博客 457

Codeforces 492D Vanya and Computer Game

D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya and his friend Vova play a compute...

weixin_34356555的博客 147

CodeForces 492D Vanya and Computer Game

/* * 告知两人的攻速,询问致死的伤害是谁打出的 * 可以预处理出1s内所有攻击的属主 * 用小数存可能精度不够,所以将所有小数乘上x*y转换成整数,排序后遍历,判断第几下攻击是谁的 * 如果攻击属于两个人,就输出Both * 处理出1s内的合攻击力,将生命值对合攻击力取余,只判断1s内的情况 */ /*****************************************

UnknownCUnknown的专栏 462

codeforces 492D Vanya and Computer Game (二分)

D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes Vanya and his friend Vova play a computer game where they need to destroy n monsters to pas

Tc的专栏 1099

Codeforces 492D - Vanya and Computer Game (二分)

RT

一只冰熊 997
上一篇: CodeForces 493C Vasya and Basketball
下一篇: POJ 1328 Radar Installation
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值