Love丶FFC's Blog
近来,跳一跳这款小游戏风靡全国,受到不少玩家的喜爱。
简化后的跳一跳规则如下:玩家每次从当前方块跳到下一个方块,如果没有跳到下一个方块上则游戏结束。
如果跳到了方块上,但没有跳到方块的中心则获得1分;跳到方块中心时,若上一次的得分为1分或这是本局游戏的第一次跳跃则此次得分为2分,否则此次得分比上一次得分多两分(即连续跳到方块中心时,总得分将+2,+4,+6,+8...)。
现在给出一个人跳一跳的全过程,请你求出他本局游戏的得分(按照题目描述的规则)。
输入包含多个数字,用空格分隔,每个数字都是1,2,0之一,1表示此次跳跃跳到了方块上但是没有跳到中心,2表示此次跳跃跳到了方块上并且跳到了方块中心,0表示此次跳跃没有跳到方块上(此时游戏结束)。
输出一个整数,为本局游戏的得分(在本题的规则下)。
1 1 2 2 2 1 1 2 2 0
22
对于所有评测用例,输入的数字不超过30个,保证0正好出现一次且为最后一个数字。
1.对几种可能的情况进行判断。
package CCF_CSP; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class _20180301_100point { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int point = 0; //总得分 int continuationjump = 0; //连续跳跃到中心的得分情况 List<Integer> jumpcondition = new ArrayList<Integer>(); //跳跃情况 for(int i=0;i<30;i++) { jumpcondition.add(scanner.nextInt()); if(jumpcondition.get(i) == 2) //跳跃到中心 { if(i == 0) //第一次跳跃 { point += 2; continuationjump += 2; } else if(jumpcondition.get(i-1) == 1) //非第一次跳跃但前一次跳跃得1分 { point += 2; continuationjump += 2; } else //连续跳跃到中心 { continuationjump += 2; point += continuationjump; } } else if(jumpcondition.get(i) == 1) //未跳跃到中心 { point += 1; continuationjump = 0; //连续跳跃到中心点的得分清零 } else //0:结束 { break; } } System.out.println(point); } }
Abupguele
2 tumors developed bone metastases overnight cialis delivery The young elf girl s voice came from outside the bedroom, and they expressed their apologies in horror and respect, and said they wanted to leave immediately
invoimi
side effects of propecia Vitamin D plays a physiologic role in reproduction including ovarian follicular development and luteinisation, follicle- stimulating hormone sensitivity and progesterone production in human granulosa cells
jXEviou
Androgen deprivation therapy for prostate cancer and osteoporotic risk where to buy cialis