ZOJ Fiddlesticks (简单模拟)
来源:互联网 发布:excel数据标签连线 编辑:程序博客网 时间:2024/05/18 01:22
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) andc(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
23 100200 150 2008 80200 100 100 100 100 80 160 200
Sample Output
23
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){int a[50],c,n,i,j,kill,t,s;int z;cin>>z;while(z--) {cin>>n>>c;for(i=1;i<=n;i++) cin>>a[i];kill=0;t=1;i=1;s=0;while(1) {if(a[i]>0) {kill++;if(kill==n+5) break; a[i]=a[i]-c;if(a[i]<=0) {t=-t;s++;}if(s==n) break;} i+=t;if(i<1) i=n;if(i>n) i=1;}printf("%d\n",i);}return 0;}
- ZOJ Fiddlesticks (简单模拟)
- ZOJ 3897 Fiddlesticks(模拟题)
- ZOJ-3897 Fiddlesticks
- ZOJ 3897 Fiddlesticks
- ZOJ-3897-Fiddlesticks
- ZOJ-3897-Fiddlesticks
- zoj 2164 Hanafuda Shuffle简单模拟(2)
- poj 1103 & zoj 1142 Maze (图形模拟+简单搜索)
- ZOJ 3804 YY's Minions(简单模拟)
- ZOJ 3827 简单数学推导+简单模拟
- ZOJ 1138(模拟)
- ZOJ-3594 Sexagenary Cycle【简单模拟】
- zoj 3697 恶心模拟 +简单DP
- ZOJ 3220 Killing Streak(简单模拟)
- ZOJ 3897(模拟题)
- ZOJ 3705Applications (模拟)
- ZOJ 3323(B)模拟
- ZOJ 3326(E)模拟
- 接口回调传值的形象比喻
- LeetCode_remove-duplicates-from-sorted-array
- servlet生命周期
- Ztree之简单实现(一)
- HTTP协议中POST、GET、HEAD、PUT等请求方法以及一些常见错误(转载)
- ZOJ Fiddlesticks (简单模拟)
- uva 10816 Travel in Desert (最小生成树 + 最短路)
- c数组名和指针
- 网络管理技术(二)
- Streaming iPod Audio Tracks From Disk With Core Audio
- 坐井观天谈Windows桌面应用程序开发中的MVC架构(一)之个人开发之路
- Android Studio主要目录及文件简介
- Ztree之增删改查功能(二)
- Windows批处理学习之批处理简单编程