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.

2.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

复习提纲

A为例5进制理解为5^0,5^1,5^2,5^3 (1234)_5=1*4+3*5+2*25+1*125=194 (302)_8=2*8^0+0*8^1+3*8^2=2*1+0*8+3*64=194 (11000100)_2=(304)_8(302)_8不同,所以答案是C (C2)_{16}=2*1+12*16=194

#include <bits/stdc++.h>
using namespace std;

bool check(int x) {
    int sum = 0;
    while (x) {
        int a = x % 10;
        x /= 10;
        sum += a;
    }
    return sum % 2 == 0;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = n; i <= m; i++)
        if (check(i))
            cout << i << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;

    int m;
    cin >> m;
    m--;

    while (m--) {
        string t;
        for (int i = 0; i < s.size(); i++) {
            int c = 1;
            while (i + 1 < s.size() && s[i + 1] == s[i]) {
                c++;
                i++;
            }
            t = t + to_string(c) + s[i];
        }
        s = t;
    }
    cout << s << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int k;
string kill(string s) {
    int p = s[s.size() - 1]; // 最后一位是默认值
    for (int i = 0; i < s.size() - 1; i++)
        if (s[i + 1] > s[i]) {
            p = i;
            break;
        }
    string res;
    for (int i = 0; i < s.size(); i++)
        if (i != p) res += s[i];
    return res;
}

int main() {
    string s;
    cin >> s >> k;
    for (int i = 1; i <= k; i++) s = kill(s);
    cout << s << endl;
    return 0;
}