Fiddlesticks is a popular hero in LOL. When he uses third skill, he can summon a crow to attack one enemy while causing damage to the enemy. And then, the crow will attack another enemy. Now there are n enemies. Their HP respectively are a1,a2,a3,...,an. The crow can attack enemies for n+5 times in total. If all enemies are killed, the crow will also disappear.
Being attacked means the enemy's HP minus crow's damage. If a enemy's HP is not larger than 0, the enemy will be removed from the game. In other word, the enemy is killed.
Fiddlesticks always let the crow attack the first enemy firstly. And the crow will attack the second enemy secondly. One by one,1st to nth enemy will be attacked. After attacking the nth enemy, the crow will return to the first enemy(if the enemy isn't killed). But if the crow kills one enemy, it will reverse the attacking direction. For example, if crow kills the 5th enemy, it won't attack 6th enemy and it will attack 4th enemy(if the enemy isn't killed). What you have to get is the serial number of the enemy who was attack finally.

Input
The first line of the input contains a single integer T, the number of test cases, followed by the input data for each test case. In each test case, you should input n(2<=n<=20) and c(50<=c<=100) in one line. n is the number of enemies, and c is the damage of the crow. Then you should input the n enemies' HP(50<=an<=200) in one line.
Output
The output contains exactly T lines, each corresponding to a test case. Each line should contain a single number that is the serial number of the enemy who was attacked finally.
Sample Input
2 3 100 200 150 200 8 80 200 100 100 100 100 80 160 200
Sample Output
2 3
题意:Fiddlesticks面对n个小怪,一开始他会攻击第1只小怪,扣c的血量,而第1只小怪收到伤害后会反弹给右边的(即第2只)小怪c的伤害,当一只小怪被反弹死后,会将伤害反向反弹,问经过n+5次反弹之后,最后受到攻击的小怪是哪一只?
解题思路:其实这是一道比较简单的模拟题,我们可以用一个变量标记反弹的方向,因为n比较小,反弹次数也有限,所以我们每次查找未被攻击死的小怪就可以了,记录每次攻击的小怪的编号,最终保留的就是最后被攻击的小怪
有一种情况是,还未反弹n+5次,所有的小怪就死光了,这样就要跳出循环,否则在找为被打死的小怪时会陷入死循环。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
using namespace std;
const int N = 25;
const int inf = 1000000005;
const int mod = 2009;
int s[N];
int main()
{
int t,n,i,c,j,flag,ans,k;
scanf("%d",&t);
while(t--)
{
flag=1;j=0;ans=k=0;
scanf("%d%d",&n,&c);
for(i=0;i<n;i++)
scanf("%d",&s[i]);
for(i=0;i<n+5;i++)
{
j=(j+n)%n;//printf("%d ",j);
s[j]-=c;ans=j+1;
if(s[j]<=0)
{
flag=-flag;
k++;
if(k==n)
break;
}
if(flag==1)
{
j++;
while(s[(j+n)%n]<=0)
j++;
}
else
{
j--;
while(s[(j+n)%n]<=0)
j--;
}
}
printf("%d\n",ans);
}
return 0;
}菜鸟成长记

本文深入探讨了游戏开发领域的关键技术,包括游戏引擎、编程语言、硬件优化等,并重点介绍了AI音视频处理在游戏中的应用,如语音识别、图像处理、AR效果等。同时,文章还涉及了自动化测试、性能优化等现代开发流程,旨在提供全面的游戏开发与AI音视频处理技术指南。
444

被折叠的 条评论
为什么被折叠?



