题解列表

筛选

优秀的拆分

摘要:解题思路:1.奇数不存在优秀的拆分,因为2的正整数次方都是偶数,偶数+偶数=偶数2.题目求一个数拆成2的正整数次方相加,使用位运算可以很简便的完成注意事项:1.<<是左移,左移一位相当于*2,左移两位……

1981: 输出M到N的数

摘要:无脑打印。#include<bits/stdc++.h> using namespace std; int main(){     int a,b;     cin >> a >> b;……

1985: 分段计算

摘要:#include<bits/stdc++.h> using namespace std; int main(){     int x;     cin >> x;     if(x<3)……

最小公倍数 最大公约数

摘要:解题思路:无注意事项:无参考代码:#include <iostream>using namespace std;int func(int a, int b){ return a % b == 0 ? ……

2023: 求逆序对个数

摘要:解题思路:其实就是求逆序数的问题,以题目给出的测试数据为例4 2 2 8 5 2 7 3对于第一个4来说,后面有4个比它小的数,依次类推,4+4+2+1=11这里采用冒泡排序将数组排序,用z表示需要用……

顺序赋值再输出

摘要:解题思路:顺序赋值注意事项:参考代码:import java.util.Scanner;public class Main { public static void main(String[] arg……

2016: 新生的入队仪式

摘要:解题思路:让我们先来读一下题,如果新生是最高的,就站在之前最高的右面,否则老师会让他站在最高的左边或者右边的队列里按照身高站(1表示左,2表示右)参考代码:#include <stdio.h> ……

2018: 飞奔的马

摘要:解题思路:每交换一次就加上两位置之差*2参考代码:#include <stdio.h> #include <stdlib.h> int main()  { int i,j,k; in……

2019: 滚动的榜单

摘要:解题思路:对k前面的数进行排序,然后找到k的位置,因为是从小到大排的序,所以用k-i来输出参考代码:#include <stdio.h> #include <stdlib.h> int gg(……