You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.2 KiB

办法:将十六进制向十进制化,而不是 将十进制向十六进制转换。上来直接排除D(出题人不会太仁慈,否则就直接秒杀了),其它的靠算。

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
int main() {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[1] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
bool isQm(int x) {
    int t = x;
    while (t) {
        int a = t % 10;
        if (a > 0 && x % a > 0) return false;
        t /= 10;
    }
    return true;
}

int main() {
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    for (int i = n; i <= m; i++)
        if (isQm(i)) {
            cout << i << " ";
            cnt++;
        }
    if (cnt == 0) cout << -1;
    return 0;
}