给定一个单链表 L,我们将每 K 个结点看成一个区块(链表最后若不足 K 个结点,也看成一个区块),请编写程序将 L 中所有区块的链接反转。例如:给定 L 为 1→2→3→4→5→6→7→8,K 为 3,则输出应该为 7→8→4→5→6→1→2→3。 输入格式: 每个输入包含 1 个测试用例。每个测试用例第 1 行给出第 1 个结点的地址、结点总个数正整数 N (≤105)、以及正整数 K (
题目描述 Given a tree, you are supposed to tell if it is a complete binary tree. 翻译:给定一棵树,你需要说出它是否是一棵完全二叉树。 Input Specification: Each input file contains one test case. For each case, the first line g
Grigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to ci. Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index i
Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question. Suppose you are given a positive integer a. You want to choose some integer b from
Description n支队伍打比赛,每两支队伍恰好比赛一场。平局时各得1分,而有胜负时胜者3分,负者0分。 假设三支队伍得分分别为3, 3, 3,则可能有两种情况: 队伍 A B C 得分 A - 3 0 3 B 0 - 3 3 C 3 0 - 3 队伍 A B C 得分 A - 0 3 3 B 3 - 0 3 C 0 3 - 3 给出n支队伍的最终得分(即所有比赛均已结
题目链接https://pintia.cn/problem-sets/994805342720868352/problems/994805359372255232 题目大意:给出一棵树的结构,判断是否为完全二叉树。如果是,输出YES和最后一个节点的index;否则输出NO和根节点index 思路:建树,找到根节点。然后遍历树,给每个节点赋值一个val,从1开始,那么二叉树,左儿子val = v