ZJNU 2212 - Turn-based game

Mr.Lee每隔1/x s攻击一次,cpu每隔1/y s攻击一次

因为时间与答案无关,最后只看boss受到了多少次攻击

所以可以在每个人的频率上同时乘以xy

即Mr.Lee每隔y s攻击一次,cpu每隔x s攻击一次

这样看虽然时间延长但是结果不变

就可以二分查找出打败boss用时,最后再根据时间判断谁给予的最后一击

二分出用时t,则t%x==0表示cpu给予最后一击

t%y==0表示Mr.Lee给予最后一击

 1 #include<stdio.h>
 2 int main(){
 3     long long n,x,y,k,l,r,m,d1,d2;
 4     scanf("%lld%lld%lld",&n,&x,&y);
 5     while(n--){
 6         scanf("%lld",&k);
 7         l=1;
 8         r=1e15;
 9         while(l<r){
10             m=(l+r)>>1;
11             if(m/x+m/y>=k)
12                 r=m;
13             else
14                 l=m+1;
15         }
16         d1=r%x;
17         d2=r%y;
18         if(!d1&&!d2)
19             puts("Obviously Ruddy Eye is the first!");
20         else if(d1&&!d2)
21             puts("I like Ruddy Eye forever!");
22         else if(!d1&&d2)
23             puts("Spicy chicken computer!");
24     }
25
26     return 0;
27 }

原文地址:https://www.cnblogs.com/stelayuri/p/12238682.html

时间: 2024-10-13 18:37:15

ZJNU 2212 - Turn-based game的相关文章

JPA/EJB3 Relationship

The Java Persistence API introduced in Java EE 5 is a subset of EJB 3 and replaces the persistence solution of EJB 2.0 CMP. JPA 1.0 has been defined as part of the EJB 3.0 specification (JSR 220) but can be used without and outside an EJB container.

【转】A Technical Comparison of TTLS and PEAP

A Technical Comparison of TTLS and PEAP by Matthew Gast author of 802.11 Wireless Networks: The Definitive Guide10/17/2002 Related Reading 802.11 Wireless Networks: The Definitive GuideCreating and Administering Wireless NetworksBy Matthew Gast Broad

[转载]AngularJS and scope.$apply

http://jimhoskins.com/2012/12/17/angularjs-and-apply.html http://www.cnblogs.com/zhrj000/p/3383898.html If you’ve written a non-trivial amount of code in AngularJS, you may have come across the $scope.$apply() method. On the surface, it may seem like

Information Centric Networking Based Service Centric Networking

A method implemented by a network device residing in a service domain, wherein the network device comprises an information centric networking (ICN) transport layer and a service access layer (SAL) for handling context-aware service logistics and serv

Instances Based on Opencv2: A Simple Analysis of MVC Architecture

A few months ago, one of my friends asked me for a favor that he wanted me to help him out with his digital recognition project. Fortunately, I had decided to go further for a master degree and I had plenty of time, moreover I was totally interested

Adaptively handling remote atomic execution based upon contention prediction

In one embodiment, a method includes receiving an instruction for decoding in a processor core and dynamically handling the instruction with one of multiple behaviors based on whether contention is predicted. If no contention is predicted, the instru

Troubleshooting routing topology based on a reference topology

In one embodiment, a computing device (e.g., border router or network management server) transmits a discovery message into a computer network, such as in response to a given trigger. In response to the discovery message, the device receives a unicas

真实场景中WebRTC 用到的服务 STUN, TURN 和 signaling

FQ收录转自:WebRTC in the real world: STUN, TURN and signaling WebRTC enables peer to peer communication. BUT... WebRTC still needs servers: For clients to exchange metadata to coordinate communication: this is called signaling. To cope with network addre

Graphics-Processing Architecture Based on Approximate Rendering

BACKGROUND The present invention generally relates to the processing of graphics data, and particularly relates to methods and apparatus for controlling approximation errors in the rendering of three-dimensional graphics data. State-of-the-art three-