一道二分答案题,判断时只需将距离遍历一遍,即可统计出需要移走多少块石头 #include<cstdio> using namespace std; int a[50005], n, m, t; bool judge(int x) { int s = 0, now = 0; for(int i = 1; i <= n; i++) { if(a[i] - a[now] < x) s++;
题目描述 一年一度的“跳石头”比赛又要开始了! 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石。组委会已经选择好了两块岩石作为比赛起点和终点。在起点和终点之间,有N块岩石(不含起点和终点的岩石)。在比赛过程中,选手们将从起点出发,每一步跳向
import random#根据输入参数显示对应结果while True:#获取输入参数play = int(input("请输入您得动作(0剪刀 1石头 2布 或退出程序 3):"))#电脑随机动作动作computer = random.randint(0, 2) if (play ==0 and computer ==2) or (play == 1 and computer ==0) or(play == 2 and comput